Get-CMScript
Get a PowerShell script in Configuration Manager.
Syntax
ByName (Default)
Get-CMScript
[-Author <String>]
[-Fast]
[-ScriptName <String>]
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[<CommonParameters>]
ById
Get-CMScript
-ScriptGuid <String>
[-Author <String>]
[-Fast]
[-DisableWildcardHandling]
[-ForceWildcardHandling]
[<CommonParameters>]
Description
Use this cmdlet to get a Configuration Manager PowerShell script. These scripts are integrated and managed in Configuration Manager. For more information, see Create and run PowerShell scripts from the Configuration Manager console.
Note
Run Configuration Manager cmdlets from the Configuration Manager site drive, for example PS XYZ:\>
. For more information, see getting started.
Examples
Example 1: Get all unapproved scripts
This command gets all scripts in Configuration Manager that aren't approved.
Get-CMScript -Fast | Where-Object { -not $_.ApprovalState }
Example 2: Get scripts by using name
This command gets all scripts that have a name that begins with the letter D
.
Get-CMScript -ScriptName "D*"
Example 3: Get scripts from a specific author
This command gets all scripts for the author with username jqpublic. Since it uses the asterisk (*
) wildcard, the specific domain doesn't matter. It then returns a table that lists the script name, approval state, and last update time.
Get-CMScript -Fast -Author "*jqpublic" | Select-Object ScriptName, ApprovalState, LastUpdateTime
Parameters
-Author
Specify the author of the script to get. For example, contoso\jqpublic
.
You can use wildcard characters:
*
: Multiple characters?
: Single character
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | True |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-DisableWildcardHandling
This parameter treats wildcard characters as literal character values. You can't combine it with ForceWildcardHandling.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Fast
Add this parameter to not automatically refresh lazy properties. Lazy properties contain values that are relatively inefficient to retrieve. Getting these properties can cause additional network traffic and decrease cmdlet performance.
If you don't use this parameter, the cmdlet displays a warning. To disable this warning, set $CMPSSuppressFastNotUsedCheck = $true
.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-ForceWildcardHandling
This parameter processes wildcard characters and may lead to unexpected behavior (not recommended). You can't combine it with DisableWildcardHandling.
Parameter properties
Type: | SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-ScriptGuid
Applies to version 2010 and later. Specify the GUID of a script to get.
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
ById
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-ScriptName
Specify a script name to get.
You can use wildcard characters:
*
: Multiple characters?
: Single character
Parameter properties
Type: | String |
Default value: | None |
Supports wildcards: | True |
DontShow: | False |
Parameter sets
ByName
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
None
Outputs
IResultObject
IResultObject
Notes
This cmdlet returns an object for the SMS_Scripts WMI class.