How to Run CM Powershell commands?

Duchemin, Dominique 2,006 Reputation points
2023-05-09T21:52:19.4633333+00:00

Hello,

I launched the CM Console > Connect Via Windows Powershell ISE (if I use Connect Via Windows PoweShell it works)

but when I try to launch the default ps1 I got an error:

PS C:\Windows\system32> C:\Users\xxxxxxxx\AppData\Local\Temp\ISEConnect_UCP - Company.ps1
File C:\Users\xxxxxxxx\AppData\Local\Temp\ISEConnect_UCP - Company.ps1 cannot be loaded. The file C:\Users\xxxxxxxx\AppData\Local\Temp\ISEConnect_UCP - 
Company.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting 
execution policy, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170.
    + CategoryInfo          : SecurityError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : UnauthorizedAccess

then I am trying to run:

Get-CMAntimalwarePolicy

but I am getting an error, any idea?

Thanks,
Dom

PS C:\Windows\system32> Get-CMAntimalwarePolicy
Get-CMAntimalwarePolicy : This command cannot be run from the current drive. To run this command you must first connect to a Configuration Manager drive.
At line:1 char:1
+ Get-CMAntimalwarePolicy
+ ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : DeviceError: (Microsoft.Confi...timalwarePolicy:GetAntimalwarePolicy) [Get-CMAntimalwarePolicy], InvalidOperationException
    + FullyQualifiedErrorId : CommandCannotExecuteFromCurrentDrive,Microsoft.ConfigurationManagement.PowerShell.Cmdlets.EP.GetAntimalwarePolicy
																																
Microsoft Configuration Manager
0 comments No comments
{count} votes

Accepted answer
  1. AllenLiu-MSFT 41,691 Reputation points Microsoft Vendor
    2023-05-10T02:05:18.45+00:00

    Hi, @Duchemin, Dominique

    Thank you for posting in Microsoft Q&A forum again.

    I got the same issue as you in my environment, if we get the PowerShell script is not digitally signed issue, it might be because your Execution Policy is restricted.

    We can set the execution policy to bypass the current PowerShell session with this command and click "Yes to All".

    Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
    
    

    1


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Add comment".

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful