Difference between revisions of "Power Shell"

Jump to navigation Jump to search
m (→‎Using WMI: Added Win32_userAccount)
m (Added "Credentials")
Line 1: Line 1:
== Using WMI ==
== Credentials ==
When running commands that require a connection to a remote machine its useful to be able to store a user/pass combination so that you aren't repeatedly prompted every time you run a command.  Create a credential object, then supply that in place of a username in a command
 
<pre>
PS H:\> $cred = Get-Credential
 
cmdlet Get-Credential at command pipeline position 1
Supply values for the following parameters:
Credential
PS H:\> Get-WMIObject -query "SELECT * FROM Win32_OperatingSystem" -credential $cred -computer 159.104.224.167
 
SystemDirectory : C:\WINDOWS\system32
Organization    : TF
BuildNumber    : 3790
RegisteredUser  : TF
SerialNumber    : 69712-640-3560061-45009
Version        : 5.2.3790
</pre>
 
 
== WMI ==


Cmdlet for using WMI via PowerShell is '''Get-WMIObject''', which has an alias of '''gwmi''', for example...
Cmdlet for using WMI via PowerShell is '''Get-WMIObject''', which has an alias of '''gwmi''', for example...