Hi
So I have been trying to import a scheduled task I had originally created through the GUI. The task was exported successfully and I also manually imported on a couple of servers to check this out without any problems.
I have about 60-70 servers in total which I would like to roll this scheduled task out to.
I have the following script:
$txtFile="C:\Scripts\ComputerNames.txt";Invoke-Command -ComputerName (Get-Content $txtFile) -ScriptBlock {schtasks.exe /create /RU domain\Username /RP Password /TN ExportLogs /XML "\\NAS\Share\Tasks\EventViewer.xml"}
I started testing with 10 servers and the task, this rolled out to only 2 servers with the others stating remote exception, wrong username or password. I have confirmed the administrator account I am using is a part of the domain admins security group and that the domain admins is a part of the local administrator group for each server. I have also confirmed the administrator account has full control over the NAS area. The administrator account can also RDP and start a PSSession remotely on these problematic servers. WinRM was restarted on a few servers but this had no effect.
Changing the script to run for one of the problematic servers also yields the same result, remote exception, wrong username or password. I have also ensured PSRemoting is enabled but no change.
Invoke-Command -ComputerName $Server_Name$ -ScriptBlock {schtasks.exe /create /RU domain\Username /RP Password /TN ExportLogs /XML "\\NAS\Share\Tasks\EventViewer.xml"}
The environment is a mix of Server 2016 datacenter and Windows Server 2012 R2 datacentre. All servers are reachable and on the same network.
The only way I have managed to run this for some of these problematic servers is by importing through the GUI or running the powershell script locally for the server.
Any help would be appreciated.
Regards,
Gareth