-
PowerShell Tip – How to check number or cores, logical processors and Hyper-threading on multiple hosts?
It is very simple… Get-CimInstance -ClassName Win32_Processor -CimSession host1, host2 | Format-Table PSComputerName, NumberOfCores, NumberOfLogicalProcessors
-
PowerShell Tip – How to remove AD OU and all child objects (another OUs, users, groups, computers)?
How to remove Active Directory Organizational Unit with all child objects (another OUs, users, groups, computers)? It is simple. The trick is to use Remove-ADObject -Recursive. Get-ADOrganizationalUnit -Identity ‘OU=ToDelete,DC=ad,DC=fabrikam,DC=com’ | Set-ADOrganizationalUnit -ProtectedFromAccidentalDeletion:$false -PassThru | Remove-ADObject -Recursive -Confirm:$false
-
PowerShell Tip – How to immediately access new disk after mount (Mount-VHD, Mount-DiskImage)
If you inside of a script mount a disk or do other operation that add another disk into system (unlock TrueCrypt protected volume) then you will not be able immediately access it. For example Get-ChildItem -Path X: will not work and you will get an error like you want to access a partition that does…
-
Convert object in PowerShell (for example [PsCustomObject]) into hash table source code
I needed a simple and reusable PowerShell code to convert any object into hash table that can be copy and pasted as source code. I wrote this: $outputItem = ‘@{‘ $MyCustomObject.PSObject.Properties.Name | Where-Object -FilterScript { $_ -ne ‘ComputerName’ } | ForEach-Object -Process ` { if ($interfaceItemIpConfigurationItem.$_ -is [bool]) { $valueItem = ‘${0}’ -f $MyCustomObject.$_.ToString().ToLower() }…