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 kill frozen service

Hi Guys,

This happens very often that you are going to services.msc and you want to restart service and after a few seconds, you see that service is hung (grey out).

Step1. Grab the name of the service.

Step2. Get PID of the service.
sc queryex servername

looking for PID

Step3. Kill the PID
taskkill /f /pid [PID]

That’s all, now you can start service in service console.

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 ":", "$"
$VHDRemotePath="\\"+$VM.ComputerName+"\"+$VHDRemotePath
$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 🙂

How to fix broken group policy object or Direct Access

Hi Guys,

Some of my users are able to break Direct Access and when they run gpupdate /force they are getting

“The processing of Group Policy failed. Windows could not apply the registry-based policy settings for the Group Policy object LocalGPO. Group Policy settings will not be resolved until this event is resolved. View the event details for more information on the file name and path that caused the failure.”

To fix it:
Go to the: C:\Windows\System32\GroupPolicy (This folder is hidden)
Go to the machine folder: rename registry.pol to registry.bak
Run gpupdate /force
Restart computer.

That’s all.

How to export all mailboxes to PST file on Exchange.

Hi this is my easy way to export all mailboxes to PST on the Exchange servers.

Step1: We have to give our user permission to EXPORT mailboxes.

New-ManagementRoleAssignment -role "Mailbox Import Export" -User OUR_USER

Step2: Please create folder where you want to save PST files.

Step3: Export user names.

Get-mailbox| Select-Object -ExpandProperty Name | Out-File -FilePath "c:\user_list.txt"

Step4: Run script bellow. Please remember to change path where you want save PST files. Very important it has to be UNC path.
foreach ($user in $content)
{
New-MailboxExportRequest -Mailbox $user -FilePath "\\MY-Server\PST\$user Mailbox.pst"
}

Sysvol folder doesn’t exist in Windows 2012/16 after deploying DC in AD 2008.

Hi guys,

After deployed Windows 2012/16 and promoting it to AD SYSVOL folder is not sync with Windows 2008. Problem this exists because Windows 2008 in default is using FSRM when Windows 2012/16 DFSR to sync SYSVOL.

Fix: migrating FRS to DFSR SYSVOL.
1. If you deployed Windows 2012 and have this problem please uninstall AD role from new server.

2. Go to your old AD server and raised domain level to at least Windows Sever 2008.

Set-ADDomainMode -Identity domain.name.com -DomainMode Windows2008Domain

FSRM to DFSR Migration
3. Migrate to Prepared State
Type: Dfsrmig /setglobalstate 1

Type: Dfsrmig /getmigrationstate

When all DCs are ready, the output will look like this:

4.Migrate to Redirected State
Type: Dfsrmig /setglobalstate 2

Type: Dfsrmig /getmigrationstate

When all DCs are ready, the output will look like this:

5.Migrate to Eliminated State
Type: Dfsrmig /setglobalstate 3

Type: Dfsrmig /getmigrationstate

When all DCs are ready, the output will look like this:

Your migration is complete.

5. Please install AD role on the new sever.

6. Check SYSVOL folder on the new server.

That’s all!