Skip to content

Instantly share code, notes, and snippets.

@obsoleted
Created February 4, 2016 18:17
Show Gist options
  • Select an option

  • Save obsoleted/f36af20b87cb8ec21fcf to your computer and use it in GitHub Desktop.

Select an option

Save obsoleted/f36af20b87cb8ec21fcf to your computer and use it in GitHub Desktop.
Get thing info
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