AuthorizationManager.ShouldRun Method

Determines whether a command should be run.

Namespace: System.Management.Automation
Assembly: System.Management.Automation (in System.Management.Automation.dll)

Dim commandInfo As CommandInfo
Dim origin As CommandOrigin
Dim host As PSHost
Dim reason As Exception
Dim returnValue As Boolean

returnValue = Me.ShouldRun(commandInfo, origin, host, reason)

protected internal virtual bool ShouldRun (
	CommandInfo commandInfo,
	CommandOrigin origin,
	PSHost host,
	out Exception reason
protected boolean ShouldRun (
	CommandInfo commandInfo, 
	CommandOrigin origin, 
	PSHost host, 
	/** @attribute OutAttribute() */ /** @ref */ Exception reason



A CommandInfo object that describes the command to be run.


A CommandOrigin object that describes the dispatch origin of the command.


A PSHost object that describes the host that provides communications between the Windows PowerShell runtime and the command line.


If your authorization policy blocks the execution of a command, this parameter holds an Exception object that contains the reason why the command was blocked. When deriving from this class, be sure to populate this parameter with an exception describing the reason why your implementation blocked the execution of the command.

Return Value

True if the command should be run; otherwise, false is returned.

When deriving from this class to create your own authorization policy, override this method with the logic specific to your needs.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


Target Platforms

© 2014 Microsoft