Skip to content

Latest commit

 

History

History
210 lines (150 loc) · 4.81 KB

File metadata and controls

210 lines (150 loc) · 4.81 KB
external help file Module Name ms.date online version schema
AdminUI.PS.dll-Help.xml
ConfigurationManager
12/28/2021
2.0.0

New-CMScript

SYNOPSIS

Create a PowerShell script in Configuration Manager.

SYNTAX

ByFile

New-CMScript [-Fast] -ScriptFile <String> -ScriptName <String> [-DisableWildcardHandling]
 [-ForceWildcardHandling] [-WhatIf] [-Confirm] [<CommonParameters>]

ByText

New-CMScript [-Fast] -ScriptName <String> -ScriptText <String> [-DisableWildcardHandling]
 [-ForceWildcardHandling] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

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.

EXAMPLES

Example 1: Create a script with text

This example creates a new script named CMScript. It specifies the text of the script.

New-CMScript -ScriptName "CMScript" -ScriptText 'Write-Host "New Script"'

Example 2: Create a script from a file

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

PARAMETERS

-DisableWildcardHandling

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

-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.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ForceWildcardHandling

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

-ScriptFile

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

-ScriptName

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

-ScriptText

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

-Confirm

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

-WhatIf

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

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

None

OUTPUTS

System.Object

NOTES

RELATED LINKS

Approve-CMScript Deny-CMScript Get-CMScript Invoke-CMScript Remove-CMScript Set-CMScript

Create and run PowerShell scripts from the Configuration Manager console