Created
February 4, 2016 18:17
-
-
Save obsoleted/f36af20b87cb8ec21fcf to your computer and use it in GitHub Desktop.
Get thing info
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
| Param( | |
| [parameter(Mandatory=$false)] | |
| [String] | |
| $thing | |
| ) | |
| # I don't know what I'm doing. So whatever man. | |
| $trustedHostsPath = "WSMan:\localhost\Client\TrustedHosts" | |
| $targetHost = "ThingLabs$thing" | |
| $secpasswd = ConvertTo-SecureString "p@ssw0rd" -AsPlainText -Force | |
| $mycreds = New-Object System.Management.Automation.PSCredential ("$targetHost\Administrator", $secpasswd) | |
| set-item $trustedHostsPath -Value "ThingLabs$thing" -Force | |
| $status = invoke-command -ComputerName $targetHost -ScriptBlock { $date = get-date; $version = (get-item -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').GetValue("BuildLabEx"); "Date: $date, Version: $version" } -Credential $mycreds | |
| write-host -ForegroundColor Yellow "$targetHost : $status" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment