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:

 

About these ads
This entry was posted in Powershell. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s