Freitag, 9. Oktober 2015

Crazy Powershell Oneliners

Here i present some 'useful' Oneliners - no need to understand them, will be extendet over the time

#Binding Order


Get IP Binding Order, it reads a registry key and print out the IPs

([WMIClass]"Root\Default:StdRegProv").GetMultiStringValue(2147483650,"SYSTEM\CurrentControlSet\services\Tcpip\Linkage","Bind").sValue|%{$(Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "SettingID = '$($_.Substring(8))'").IPAddress}

For a lesser known enviroment you properly want to know if your Binding serves the NIC first which has the default Gateway.

([WMIClass]"Root\Default:StdRegProv").GetMultiStringValue(2147483650,"SYSTEM\CurrentControlSet\services\Tcpip\Linkage","Bind").sValue|%{$(Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "SettingID = '$($_.Substring(8))'")|Select IPAddress, Description,DefaultIPGateway}

You should see the gateway on the first line, if not something is wrong.

Over Remote - this is surely usefull for healthchecks

$(Get-WmiObject -computer [COMPUTERNAME] -Namespace "Root\Default" -List | ?{$_.Name -eq "StdRegProv"}).GetMultiStringValue(2147483650,"SYSTEM\CurrentControlSet\services\Tcpip\Linkage","Bind").sValue|%{$(Get-WmiObject -computer [COMPUTERNAME] -Class Win32_NetworkAdapterConfiguration -Filter "SettingID = '$($_.Substring(8))'")|Select IPAddress, Description,DefaultIPGateway}

#Get all RSAT Tools

dism /Online /Get-Capabilities|Select-String Rsat|%{dism /Online /Add-Capability /CapabilityName:$($($_|Out-String).Split(':')[1].Trim())}

Keine Kommentare:

Kommentar veröffentlichen