external help file | Module Name | ms.date | online version | schema |
---|---|---|---|---|
AdminUI.PS.dll-Help.xml |
ConfigurationManager |
12/28/2021 |
2.0.0 |
Create a PowerShell script in Configuration Manager.
New-CMScript [-Fast] -ScriptFile <String> -ScriptName <String> [-DisableWildcardHandling]
[-ForceWildcardHandling] [-WhatIf] [-Confirm] [<CommonParameters>]
New-CMScript [-Fast] -ScriptName <String> -ScriptText <String> [-DisableWildcardHandling]
[-ForceWildcardHandling] [-WhatIf] [-Confirm] [<CommonParameters>]
Use this cmdlet to create a new 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.
This example creates a new script named CMScript. It specifies the text of the script.
New-CMScript -ScriptName "CMScript" -ScriptText 'Write-Host "New Script"'
This example creates a new script named ImportScript. It imports the script from an existing file on a network share.
New-CMScript -ScriptName "ImportScript" -ScriptFile "\\abc\importedscript.ps1" -Fast
This parameter treats wildcard characters as literal character values. You can't combine it with ForceWildcardHandling.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
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
.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This parameter processes wildcard characters and may lead to unexpected behavior (not recommended). You can't combine it with DisableWildcardHandling.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify the path to a PowerShell script file (.ps1
). The text of the file is used for the script in Configuration Manager.
Type: String
Parameter Sets: ByFile
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify a name for the script to create.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Specify the text of the script to create.
Type: String
Parameter Sets: ByText
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet doesn't run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Approve-CMScript Deny-CMScript Get-CMScript Invoke-CMScript Remove-CMScript Set-CMScript
Create and run PowerShell scripts from the Configuration Manager console