Assert ElevatedUser - dsccommunity/DscResource.Common GitHub Wiki
Assert that the user has elevated the PowerShell session.
Assert-ElevatedUser [[-ErrorMessage] <String>] [<CommonParameters>]
Assert that the user has elevated the PowerShell session. The command will throw a statement-terminating error if the script is not run from an elevated session.
Assert-ElevatedUser
Throws an exception if the user has not elevated the PowerShell session.
Assert-ElevatedUser -ErrorMessage 'A custom error message to throw'
Throws an exception if the user has not elevated the PowerShell session.
`Assert-ElevatedUser -ErrorAction 'Stop'`
This example stops the entire script if it is not run from an elevated PowerShell session.
The error message to assign to the exception.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 1
Default value: $script:localizedData.ElevatedUser_UserNotElevated
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.