Difference between revisions of "Power Shell"

Jump to navigation Jump to search
72 bytes added ,  21:59, 18 January 2010
m
→‎WMI: Added Syntax Highlight
m (→‎Variables: Added Syntax Highlight)
m (→‎WMI: Added Syntax Highlight)
Line 79: Line 79:
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...


<pre>
<source lang="powershell">
PS H:\> Get-WMIObject -query "Select * from Win32_OperatingSystem"
PS H:\> Get-WMIObject -query "Select * from Win32_OperatingSystem"


Line 129: Line 129:
FullName    : Ypos-Consulting GmbH
FullName    : Ypos-Consulting GmbH
Name        : pptp_ypos
Name        : pptp_ypos
</pre>
</source>




Line 135: Line 135:


In order to find the correct class use...
In order to find the correct class use...
<pre>
<source lang="powershell">
Get-WMIObject -list -credential $cred -computer 159.104.224.167 | Select-String -InputObject {$_.Name} Win32*
Get-WMIObject -list -credential $cred -computer 159.104.224.167 | Select-String -InputObject {$_.Name} Win32*
</pre>
</source>


To then see all the properties of a class use (doesn't work on remote machines (access denied) - this is a known bug in Power Shell v1)...
To then see all the properties of a class use (doesn't work on remote machines (access denied) - this is a known bug in Power Shell v1)...
<pre>
<source lang="powershell">
Get-WMIObject Win32_BIOS | Format-List *
Get-WMIObject Win32_BIOS | Format-List *
</pre>
</source>


[http://technet.microsoft.com/en-gb/magazine/2009.02.windowspowershell.aspx TechNet article: Windows PowerShell Best Inventory Tool Ever!]
[http://technet.microsoft.com/en-gb/magazine/2009.02.windowspowershell.aspx TechNet article: Windows PowerShell Best Inventory Tool Ever!]

Navigation menu