W2KSG: Using Strings

We come to Listing 2.6 - using strings as variables

Script Center Home > Microsoft Windows 2000 Scripting Guide > Scripting Concepts and Technologies for System Administration > VBScript Primer > VBScript Overview > Strings Strings as Variables

In this listing we add the ability to specify the computer  we are working with. WMI is great for remote administration and if you seen my recent posts PowerShell has fantastic WMI support

$convert = 1MB
$computer = "pcrs2"

Get-WmiObject -ComputerName $computer -Class Win32_LogicalDisk -Filter "DeviceId='C:'" | Format-List @{Label="FreeSpace(MB)";Expression={[int]($_.FreeSpace/$convert)}}

Only addition is that we have defined a variable $computer to hold the computer name we want to interrogate.  In PowerShell we simply use with the -Computername parameter. Simple.

 

Share this post :

 

Technorati Tags:

 

Leave a Reply