Last active
January 21, 2018 19:38
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Even runs on Azure
