I hereby claim:
- I am julianwood on github.
- I am julianwood (https://keybase.io/julianwood) on keybase.
- I have a public key whose fingerprint is 5845 3911 005E D2B2 6CA0 9D9D 3D31 0270 F228 AC08
To claim this, I am signing this object:
#!/bin/bash | |
set -euxo pipefail | |
ACCOUNT_ID=$(aws sts get-caller-identity --query 'Account' --output text) | |
CURRENT_REGION=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone | sed 's/\(.*\)[a-z]/\1/') | |
RED='\033[0;31m' | |
YELLOW='\033[1;33m' | |
NC='\033[0m' |
Connect-VIServer MyvCenterServer | |
$VMs = Get-VM -Location "Workstations" | Where { ($_.PowerState -eq "PoweredOn") -and ($_.Guest.OSFullName -like "*Windows*") } | |
ForEach ($VM in $VMs) { | |
Write-Host "Getting Logged on Users for: " $VM " - " $VM.Guest.HostName -ForegroundColor Green | |
$LoggedOnUsers = (Get-WmiObject Win32_LoggedOnUser -ComputerName $VM.Guest.HostName | Where {$_.Antecedent -Match (Get-ADDomain).NetBIOSName } | Where {$_.Antecedent -NotMatch $env:username } | Select Antecedent -Unique | %{"{0}\{1}" -f $_.Antecedent.ToString().Split(’"‘)[1], $_.Antecedent.ToString().Split(’"‘)[3]}) -Join ";" | |
If ($LoggedOnUsers) { | |
Write-Host "Logged On Users: "$LoggedOnUsers | |
} else { | |
Write-Host "No Logged On Users: "$LoggedOnUsers | |
# Write-Host "Updating Tools on VM: "$VM |
I hereby claim:
To claim this, I am signing this object: