Easy way to fix “The trust relationship between this workstation and the primary domain failed”

This happens very often. Usually I was rejoining workstation/server to the domain. However it is easier way to do it.

  1. You have to log in to the server with a broken relationship.
  2. You have to know the name of Domain Controller (example: AD01)
$DomainCred = Get-Credential
Reset-ComputerMachinePassword -Server "AD01" -Credential $DomainCred

That’s all.

How to find SID users/groups/computers star from pa*

I had to get SID for all Users that Logon Name begin with pa

Get-ADUser -Filter {Name -like "pa*"} | Select Name,SID | Format-Table -Auto

For all Groups that Name begin with pa

Get-ADGroup -Filter {Name -like "pa*"} | Select Name,SID | Format-Table -Auto

For all Computers that Name begin with pa

Get-ADComputer -Filter {Name -like "pa*"} | Select Name,SID | Format-Table -Auto

Getting VHD size plus info using PowerShell for the all Virtual Machines on the cluster

Hi Guys,

This is was not a simple task… because of Get-VMHardDiskDrive can’t give you the size of the drive.

$VMget=Get-VM -ComputerName (Get-ClusterNode -Cluster ClusterName) | Get-VMHardDiskDrive | Select-Object -Property vmname, vmid, computername, controllertype, controllernumber,controllerlocation,path
foreach ($VM in $VMget) {
$VHDRemotePath=$VM.Path -replace ":", "$"
$vhdsize= Get-ChildItem $VHDRemotePath | select-object @{Name="SizeGB";Expression={"{0:N2}" -f ($_.length / 1GB)}}
$text = $VM.VMName + " , " + $vhdsize.SizeGB + "GB , " + $VM.Path
$text | out-file C:\Temp\VHD_Size.csv -Append

It exports to CSV however you still have to use “Text to Columns” in Excel.

Enjoy đŸ™‚