Posted in
Virtual Machine Manager,
Windows Powershell,
Windows Server |
No Comment | 9,368 views | 15/11/2013 16:56
You can get list of virtual machines and vlan ids via PowerShell with following command:
1
| Get-VM | Select Name,@{label="VlanID";expression={($_.VirtualNetworkAdapters).VlanID}} |
Get-VM | Select Name,@{label="VlanID";expression={($_.VirtualNetworkAdapters).VlanID}}
I used SCVMM 2012 SP1. Not sure about other versions.
Posted in
Windows Powershell,
Windows Server |
1 Comment | 7,339 views | 01/11/2013 20:43
You can use this script to get local group information from a list of remote servers:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| $Servers = Get-Content C:\Servers.txt
Foreach ($Server in $Servers)
{
$Groups = Get-WmiObject Win32_GroupUser –Computer $Server
$LocalAdmins = $Groups | Where GroupComponent –like '*"Administrators"'
$LocalUsers = $Groups | Where GroupComponent –like '*"Users"'
$RDPUsers = $Groups | Where GroupComponent –like '*"Remote Desktop Users"'
Write-Host "Server: $Server"
Write-Host " "
Write-Host "Local Admins:"
$LocalAdmins |% {
$_.partcomponent –match ".+Domain\=(.+)\,Name\=(.+)$" > $nul
$matches[1].trim('"') + "\" + $matches[2].trim('"')
}
Write-Host " "
Write-Host "Local Users:"
$LocalUsers |% {
$_.partcomponent –match ".+Domain\=(.+)\,Name\=(.+)$" > $nul
$matches[1].trim('"') + "\" + $matches[2].trim('"')
}
Write-Host " "
Write-Host "Remote Desktop Users:"
$RDPUsers |% {
$_.partcomponent –match ".+Domain\=(.+)\,Name\=(.+)$" > $nul
$matches[1].trim('"') + "\" + $matches[2].trim('"')
}
Write-Host " "
} |
$Servers = Get-Content C:\Servers.txt
Foreach ($Server in $Servers)
{
$Groups = Get-WmiObject Win32_GroupUser –Computer $Server
$LocalAdmins = $Groups | Where GroupComponent –like '*"Administrators"'
$LocalUsers = $Groups | Where GroupComponent –like '*"Users"'
$RDPUsers = $Groups | Where GroupComponent –like '*"Remote Desktop Users"'
Write-Host "Server: $Server"
Write-Host " "
Write-Host "Local Admins:"
$LocalAdmins |% {
$_.partcomponent –match ".+Domain\=(.+)\,Name\=(.+)$" > $nul
$matches[1].trim('"') + "\" + $matches[2].trim('"')
}
Write-Host " "
Write-Host "Local Users:"
$LocalUsers |% {
$_.partcomponent –match ".+Domain\=(.+)\,Name\=(.+)$" > $nul
$matches[1].trim('"') + "\" + $matches[2].trim('"')
}
Write-Host " "
Write-Host "Remote Desktop Users:"
$RDPUsers |% {
$_.partcomponent –match ".+Domain\=(.+)\,Name\=(.+)$" > $nul
$matches[1].trim('"') + "\" + $matches[2].trim('"')
}
Write-Host " "
}
This is a quick script that I used today. So didn’t get chance to add error handling, sorry.