Showing posts with label liner. Show all posts
Showing posts with label liner. Show all posts

Thursday, December 24, 2015

Powershell: VMware one liner to list total vm that are powered on each host

This one liner will query each host and id its cluster total vms and how many VMs are powered on
Get-VMHost | Select @{N="Cluster";E={Get-Cluster -VMHost $_}}, Name, @{N="Total_VMs";E={($_ | Get-VM).Count}},@{N="Powered_On";E={($_ | get-vm | ? {$_.powerstate -like "*ON*"}).count}} | Sort Cluster, Name | fl

Friday, September 12, 2014

PowerShell: One liner get distinguishedname for all user accounts in text file

One liner to get users from a text file and create a report of distinguishedname. You need the activedirectory module imported to run.

import-module activedirectory

gc "C:\temp\serviceaccounts.txt" | Foreach-Object {Get-ADUser -filter {CN -like $_} -Properties *} | select Name, SAMAccountName, distinguishedname | export-csv -path c:\temp\test.csv

Powershell: Microsoft Graph to add new roles to application registration

PowerShell Script Bulk add new roles to application registration in azure. Update $roles with ,Us...