Executing Commands from PowerShell script
Executing Commands from PowerShell Script PS interface to run system internal or external commands is supported via invoke-* cmdlets as listed below: PS C:> get-command Invoke-* | ft name Name Invoke-Command Invoke-Expression Invoke-History Invoke-Item Invoke-WmiMethod Invoke-WSManAction PS C:> Executing Command on Local Machine: $executable = ‘c:WindowsSystem32sc.exe’ $parameters = ‘qc’ $arguments = ‘WinRM’ $command = “$executable $parameters $arguments” Invoke-Expression $command Execution Output: PS C:> $executable = ‘c:WindowsSystem32sc.exe’ PS C:> $parameters = ‘qc’ PS C:> $arguments = ‘WinRM’ PS C:> $command = “$executable $parameters $arguments” PS C:> Invoke-Expression $command [SC] QueryServiceConfig SUCCESS SERVICE_NAME: WinRM TYPE : 20 WIN32_SHARE_PROCESS START_TYPE : 3 DEMAND_START ERROR_CONTROL : […]
Read more