Skip to content

Instantly share code, notes, and snippets.

@Agazoth
Last active January 21, 2018 19:38
Show Gist options
  • Save Agazoth/dbf1aec1b5b99c7c896d49d7081b16c1 to your computer and use it in GitHub Desktop.
Save Agazoth/dbf1aec1b5b99c7c896d49d7081b16c1 to your computer and use it in GitHub Desktop.
Gets information about Operating System and Disks - A solution to Puzzle 2 in Iron Scripter 2018 Perquel 2
function Get-WickedOSandDiskObject {
param ($ComputerName=$env:COMPUTERNAME)
$CimSession = New-CimSession -ComputerName $ComputerName
$ComputerObject = Get-CimInstance Win32_OperatingSystem -CimSession $CimSession | Select-Object *,@{n='Disks';e={Get-CimInstance Win32_LogicalDisk -CimSession $CimSession | Select-Object *,@{n='PercentageUsed';e={"{0:P}" –f $(($_.size-$_.Freespace)/$_.size)}}}}
$ComputerObject.psobject.TypeNames.Insert(0, "WickedOSandDiskObject")
$ComputerObject
}
<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
<ViewDefinitions>
<View>
<Name>RequiredInfo</Name>
<ViewSelectedBy>
<TypeName>WickedOSandDiskObject</TypeName>
</ViewSelectedBy>
<ListControl>
<ListEntries>
<ListEntry>
<ListItems>
<ListItem>
<Label>OS Name</Label>
<PropertyName>Name</PropertyName>
</ListItem>
<ListItem>
<PropertyName>Version</PropertyName>
</ListItem>
<ListItem>
<Label>Service Pack</Label>
<ScriptBlock>'{0}.{1}' -f $_.ServicePackMajorVersion,$_.ServicePackMinorVersion</ScriptBlock>
</ListItem>
<ListItem>
<Label>OS Manufacturer</Label>
<PropertyName>Manufacturer</PropertyName>
</ListItem>
<ListItem>
<Label>OS Windows Directory</Label>
<PropertyName>WindowsDirectory</PropertyName>
</ListItem>
<ListItem>
<PropertyName>Locale</PropertyName>
</ListItem>
<ListItem>
<Label>Available Physical Memory</Label>
<PropertyName>FreePhysicalMemory</PropertyName>
</ListItem>
<ListItem>
<Label>Total Virtual Memory</Label>
<PropertyName>TotalVirtualMemorySize</PropertyName>
</ListItem>
<ListItem>
<Label>Available Virtual Memory</Label>
<PropertyName>FreeVirtualMemory</PropertyName>
</ListItem>
<ListItem>
<Label>Disks</Label>
<ScriptBlock>$_.Disks | select DeviceID,PercentageUsed</ScriptBlock>
</ListItem>
</ListItems>
</ListEntry>
</ListEntries>
</ListControl>
</View>
</ViewDefinitions>
</Configuration>
iex "$(irm 'https://gist.githubusercontent.com/Agazoth/dbf1aec1b5b99c7c896d49d7081b16c1/raw/da74c98b685d5fb5c31db3e6aa7ca7920f9cc311/Get-WickedOSandDiskObject.ps1')";$(irm 'https://gist.githubusercontent.com/Agazoth/dbf1aec1b5b99c7c896d49d7081b16c1/raw/da74c98b685d5fb5c31db3e6aa7ca7920f9cc311/Get-WickedOSandDiskObject.ps1xml').outerxml | out-file $env:temp\xml.ps1xml; Update-FormatData -AppendPath $env:temp\xml.ps1xml
@Agazoth
Copy link
Author

Agazoth commented Jan 21, 2018

Even runs on Azure
screenshot_20180121-203431

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment