Category: Powershell

  • How to Deal with “无法分析响应内容,因为 Internet Explorer 引擎不可用,或者 Internet Explorer 的首次启动配置不完整” Error

    You might encounter the titular error message when executing curlor Invoke-WebRequestcommands in PowerShell console. It means that by default, Invoke-WebRequest is using the Internet Explorer engine to parse the response content, which may not be functioning properly. To resolve this issue, you can use the Invoke-WebRequest command with the -UseBasicParsing parameter to use the basic…

  • Powershell Function to Get SQL Server’s Network Protocols

    [sourcecode language=”powershell”] #Function to get SQL Server network protocols Function Get-SQLProtocols { Param([String]$ComputerName = $env:COMPUTERNAME) [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo") | out-null $Server = New-Object "Microsoft.SqlServer.Management.Smo.Server" $ComputerName $VersionMajor = $Server.VersionMajor Get-WmiObject -ComputerName $ComputerName -NameSpace root\Microsoft\SqlServer\ComputerManagement$VersionMajor -Class ClientNetworkProtocol | Select-Object ProtocolName, ProtocolDisplayName, ProtocolOrder }#End of function [/sourcecode] The output of the above function usually looks like this: ProtocolName ProtocolDisplayName ProtocolOrder sm Shared Memory 1 tcp TCP/IP…

  • Powershell Function to Get Largest Files on a Drive or in a Folder

    Ofentimes when a disk space shortage alert pops up from a specific server, I’d like to know quickly which files are the largest that I might have a way to shrink or move or delete. Here are the two funtions that I use to immediately locate the full list of top N largest files at…

  • Powershell Function to Reboot a Computer with Warning Messages

    I am fully aware that a simple [sourcecode language=”powershell”]Restart-Computer "ServerName"[/sourcecode] command can easily do the trick, but it means doing this trick a bit too easy and too harzardly. I’d like to see my own function to promt up some warnings and confirmations before I actually do the reboot. I learned this lesson by typing…

  • Powershell Function to Get SQL Server’s Errorlog Path

    This is a repost of Ed Wilson the ScriptingGuy’s awesome function: [sourcecode language=”powershell” wraplines=”false”] #Get the SQL Error Log Directory on a Server Function Get-ErrorLogPath { <# .Synopsis Returns the path to the SQL Error Log .Description This function returns the path to the SQL Error Log .Example Get-ErrorLogPath Returns the path to the SQL…

  • Two Ways to Control Services on a Remote Computer in Powershell

    I am just making a note here about the two alternatives that I found via Google. The first one is on Hey! Scripting Guy’s blog post and the second one is here. To wrap up, I am summing up the below two functions: [sourcecode language=”powershell”] #Function to start a service on remote computer Function Start-Service2…