How To: Registry - multiple Entries Multiple PCs

I am trying to edit 4 registry entries for a list of computers, Help would be appreciated in pulling it all together.

Ultimate Goal:

I need to remove any MS Office version installed on the PC

That also includes Visio or Project if it is installed

Install Office 365

To achieve the above goal, I have found a PowerShell script that will remove all office versions. That script works. To launch that script, I log onto a PC with a specific UserID, and logon scripts initiate the PowerShell Script and remove previous versions. Then I initiate the install of Office 365.

Problems I have to overcome:

1: I need to remove Office and Install Office 365 after hours, when the user of the PC is not there.

2: When I log on as my "remove office userID", sometimes I don't get my proxy settings set in my profile and I don't have Internet.

3: Logging onto the PC with my "remove office UserID"

The process I thought I would use, and seems to me to be a logical method, is to remotely alter the target PC registry so that I can run my uninstall and then install scripts.

My script so far.....

# Query AD OU to find target PCs

$O365=dsquery computer "OU=Thursday,OU=Migration,DC=test,DC=MyDomain,DC=com" -o rdn

$Usr = "test\Account"

$Pss = P@$$w0rd

$SecurePass = $Pss | ConvertTo-SecureString -AsPlainText -Force

$Creds = New-Object System.Management.Automation.PSCredential -ArgumentList $Usr, $SecurePass

foreach ($PC in $O365) {

Invoke-Command -ComputerName $PC -ScriptBlock {

Set-ItemProperty -Name AutoAdminLogon -Value 1 -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\';

Set-ItemProperty -Name ForceAutoLogon -Value 1 -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\';

Set-ItemProperty -Name DefaultUserName -Value Office365 -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\';

Set-ItemProperty -Name DefaultPassword -Value '#Inst Office' -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\';

Set-ItemProperty -Name DefaultDomainName -Value CTS -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\';

restart-Computer -force

}

}

}}

An error message I get is...

Invoke-Command : One or more computer names are not valid. If you are trying to pass a URI, use the -ConnectionUri parameter, or pass URI

objects instead of strings.

At line:12 char:1

+ Invoke-Command -ComputerName $PC -ScriptBlock {

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidArgument: (System.String[]:String[]) [Invoke-Command], ArgumentException

+ FullyQualifiedErrorId : PSSessionInvalidComputerName,Microsoft.PowerShell.Commands.InvokeCommandCommand

I've had varying success by removing the foreach portion, and replacing $PC with $O365. I was using $O365=Get-Content C:\Temp\OfficePC.txt. But even when I had some success, It was not successful enough to implement in a production. Some PCs in the list would update and reboot, and others would do nothing.

I'm not necessarily tied to any solution. I just need to achieve my goal of removing All Office versions, and, if possible, remove Visio and Project, and then install Office 365.

Your help is greatly appreciated,

thank you,

Dean