-
Notifications
You must be signed in to change notification settings - Fork 9
Assert ElevatedUser
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.
- Assert-BoundParameter
- Assert-ElevatedUser
- Assert-IPAddress
- Assert-Module
- Compare-DscParameterState
- Compare-ResourcePropertyState
- ConvertFrom-DscResourceInstance
- ConvertTo-CimInstance
- ConvertTo-HashTable
- Find-Certificate
- Get-ComputerName
- Get-DscProperty
- Get-EnvironmentVariable
- Get-LocalizedData
- Get-LocalizedDataForInvariantCulture
- Get-PSModulePath
- Get-TemporaryFolder
- Get-UserName
- New-ArgumentException
- New-ErrorRecord
- New-Exception
- New-InvalidDataException
- New-InvalidOperationException
- New-InvalidResultException
- New-NotImplementedException
- New-ObjectNotFoundException
- Remove-CommonParameter
- Set-DscMachineRebootRequired
- Set-PSModulePath
- Test-AccountRequirePassword
- Test-DscParameterState
- Test-DscProperty
- Test-IsNanoServer
- Test-IsNumericType
- Test-ModuleExist