Office 365 repair remotely with Powershell

1
2
3
4
5
6
7
$cred = Get-Credential
Enter-PSSession *computername* -cred $cred
cd 'C:\Program Files\Microsoft Office 15\ClientX64\'
.\OfficeClickToRun.exe scenario=Repair DisplayLevel=false RepairType=quickRepair forceappshutdown=true

# if quick repair did not solve it
.\OfficeClickToRun.exe scenario=Repair DisplayLevel=false RepairType=FullRepair forceappshutdown=true

Manually remove Direct Access from a client

If the client is unable to do a DNS lookup, remove the following in the registry to disable/remove Direct Access DNS config.

1
2
3
4
5
6
$reg = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient\DnsPolicyConfig'

Get-ChildItem -Path $reg |
ForEach {Remove-Item $_.pspath}

Restart-Service DNSCache -force

Powershell: Rename remote computer with WMI

To rename a computer when Rename-Computer is not available (pre Powershell 4.0)

Get-WmiObject Win32_ComputerSystem -ComputerName OLDNAME -Authentication 6 |
ForEach-Object {$_.Rename(“NEWNAME”,”PASSWORD”,”USERNAME”)}

 

You can also mask the password

$credential = Get-Credential
Get-WmiObject Win32_ComputerSystem -ComputerName OLDNAME -Authentication 6 |
ForEach-Object {$_.Rename(“NEWNAME”,$credential.GetNetworkCredential().Password,$credential.Username)}