Hi All,Super newbie to powershell and I am on Day 1 of learning..i am trying to configure a SQL Server Agent job with a Powershell step type that will execute this piece of ps code:Enter-PSSession -ComputerName XXXInvoke-Command -ComputerName XXX -ScriptBlock {DIR C:\TEMP}If I run it in PowerGUI, it works and I get the listing.If I open a cmd prompt on the server, run powershell and execute the .ps1 file it works.The error I am getting is:Executed as user: DOMAIN\USER. A job step received an error at line 1 in a PowerShell script. The corresponding line is 'Enter-PSSession -ComputerName XXX. Correct the script and reschedule the job. The error information returned by PowerShell is: 'The term 'Enter-PSSession' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. '. Process Exit Code -1. The step failed.What is wrong with my simple 2-line code within the job step? Thanks in advance.My eventual goal is to replace the scriptblock command 'DIR C:\TEMP' with the path to a .bat file on the server..
↧