Powershell scripts

5 pts.
Tags:
Disk space
MS CALs
PowerShell
PowerShell Scripts
I need a powershell script for the following:

1 - Pulling disk space from a server (all drives capacity and space left)

2 - Pulling MS CAL's from our License Server (All CALS purchased and CALs used, etc...).

Answer Wiki

Thanks. We'll let you know when a new response is added.

Get-WMIObject Win32_LogicalDisk -filter “DriveType=3″ -computer (Get-Content c:\scripts\computers.txt) | Select SystemName,DeviceID,VolumeName,@{Name=”size(GB)”; Expression={“{0:N1}” -f($_.size/1gb)}},@{Name=”freespace(GB)”; Expression={“{0:N1}” -f($_.freespace/1gb)}} | Out-GridView

—-

The above script will return information about disks from machines whose name is included in a file called “computers.txt” located in “c:\scripts”. If you want to use it to get information from a single computer you may replace this part:

<pre>-computer (Get-Content c:\scripts\computers.txt)</pre>

with this:

<pre>-computer “the-name-of-the-computer-you-want-to-check”</pre>

—-

OR

$percentWarning = 15;
$servers = Get-Content “$Env:USERPROFILE\DiskList.txt”;
$datetime = Get-Date -Format “yyyyMMddHHmmss”;

Add-Content “$Env:USERPROFILE\server disks $datetime.txt” “server,deviceID,size,freespace,percentFree”;

foreach($server in $servers)
{
$disks = Get-WmiObject -ComputerName $server -Class Win32_LogicalDisk -Filter “DriveType = 3″;

foreach($disk in $disks)
{
$deviceID = $disk.DeviceID;
[float]$size = $disk.Size;
[float]$freespace = $disk.FreeSpace;

$percentFree = [Math]::Round(($freespace / $size) * 100, 2);
$sizeGB = [Math]::Round($size / 1073741824, 2);
$freeSpaceGB = [Math]::Round($freespace / 1073741824, 2);

$colour = “Green”;
if($percentFree -lt $percentWarning)
{
$colour = “Red”;
}
Write-Host -ForegroundColor $colour “$server $deviceID percentage free space = $percentFree”;
Add-Content “$Env:USERPROFILE\server disks $datetime.txt” “$server,$deviceID,$sizeGB,$freeSpaceGB,$percentFree”;
}
}

Try this code u may get what u want !

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following