| document type | cmdlet |
|---|---|
| external help file | Microsoft.Graph.Applications-Help.xml |
| HelpUri | https://learn.microsoft.com/powershell/module/microsoft.graph.applications/add-mgserviceprincipalpassword |
| Locale | en-US |
| Module Name | Microsoft.Graph.Applications |
| ms.date | 03/27/2026 |
| PlatyPS schema version | 2024-05-01 |
| title | Add-MgServicePrincipalPassword |
Add a strong password or secret to a servicePrincipal object.
Add-MgServicePrincipalPassword -ServicePrincipalId <string> [-ResponseHeadersVariable <string>]
[-AdditionalProperties <hashtable>] [-PasswordCredential <IMicrosoftGraphPasswordCredential>]
[-Break] [-Headers <IDictionary>] [-HttpPipelineAppend <SendAsyncStep[]>]
[-HttpPipelinePrepend <SendAsyncStep[]>] [-Proxy <uri>] [-ProxyCredential <pscredential>]
[-ProxyUseDefaultCredentials] [-WhatIf] [-Confirm] [<CommonParameters>]
Add-MgServicePrincipalPassword -ServicePrincipalId <string>
-BodyParameter <IPathsIeboplServiceprincipalsServiceprincipalIdMicrosoftGraphAddpasswordPostRequestbodyContentApplicationJsonSchema>
[-ResponseHeadersVariable <string>] [-Break] [-Headers <IDictionary>]
[-HttpPipelineAppend <SendAsyncStep[]>] [-HttpPipelinePrepend <SendAsyncStep[]>] [-Proxy <uri>]
[-ProxyCredential <pscredential>] [-ProxyUseDefaultCredentials] [-WhatIf] [-Confirm]
[<CommonParameters>]
Add-MgServicePrincipalPassword -InputObject <IApplicationsIdentity>
[-ResponseHeadersVariable <string>] [-AdditionalProperties <hashtable>]
[-PasswordCredential <IMicrosoftGraphPasswordCredential>] [-Break] [-Headers <IDictionary>]
[-HttpPipelineAppend <SendAsyncStep[]>] [-HttpPipelinePrepend <SendAsyncStep[]>] [-Proxy <uri>]
[-ProxyCredential <pscredential>] [-ProxyUseDefaultCredentials] [-WhatIf] [-Confirm]
[<CommonParameters>]
Add-MgServicePrincipalPassword -InputObject <IApplicationsIdentity>
-BodyParameter <IPathsIeboplServiceprincipalsServiceprincipalIdMicrosoftGraphAddpasswordPostRequestbodyContentApplicationJsonSchema>
[-ResponseHeadersVariable <string>] [-Break] [-Headers <IDictionary>]
[-HttpPipelineAppend <SendAsyncStep[]>] [-HttpPipelinePrepend <SendAsyncStep[]>] [-Proxy <uri>]
[-ProxyCredential <pscredential>] [-ProxyUseDefaultCredentials] [-WhatIf] [-Confirm]
[<CommonParameters>]
This cmdlet has the following aliases, {{Insert list of aliases}}
Add a strong password or secret to a servicePrincipal object.
Permissions
| Permission type | Permissions (from least to most privileged) |
|---|---|
| Delegated (work or school account) | Application.ReadWrite.All, Directory.ReadWrite.All, |
| Delegated (personal Microsoft account) | Not supported |
| Application | Application.ReadWrite.OwnedBy, Directory.ReadWrite.All, Application.ReadWrite.All, |
Import-Module Microsoft.Graph.Applications
$params = @{
passwordCredential = @{
displayName = "Password friendly name"
}
}
Add-MgServicePrincipalPassword -ServicePrincipalId $servicePrincipalId -BodyParameter $params
This example shows how to use the Add-MgServicePrincipalPassword Cmdlet.
Additional Parameters
Type: System.Collections.Hashtable
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: AddViaIdentityExpanded
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
- Name: AddExpanded
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''To construct, see NOTES section for BODYPARAMETER properties and create a hash table.
Type: Microsoft.Graph.PowerShell.Models.IPathsIeboplServiceprincipalsServiceprincipalIdMicrosoftGraphAddpasswordPostRequestbodyContentApplicationJsonSchema
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: AddViaIdentity
Position: Named
IsRequired: true
ValueFromPipeline: true
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
- Name: Add
Position: Named
IsRequired: true
ValueFromPipeline: true
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''Wait for .NET debugger to attach
Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''Prompts you for confirmation before running the cmdlet.
Type: System.Management.Automation.SwitchParameter
DefaultValue: ''
SupportsWildcards: false
Aliases:
- cf
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''Optional headers that will be added to the request.
Type: System.Collections.IDictionary
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: true
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''SendAsync Pipeline Steps to be appended to the front of the pipeline
Type: Microsoft.Graph.PowerShell.Runtime.SendAsyncStep[]
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''SendAsync Pipeline Steps to be prepended to the front of the pipeline
Type: Microsoft.Graph.PowerShell.Runtime.SendAsyncStep[]
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''Identity Parameter To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
Type: Microsoft.Graph.PowerShell.Models.IApplicationsIdentity
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: AddViaIdentityExpanded
Position: Named
IsRequired: true
ValueFromPipeline: true
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
- Name: AddViaIdentity
Position: Named
IsRequired: true
ValueFromPipeline: true
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''passwordCredential To construct, see NOTES section for PASSWORDCREDENTIAL properties and create a hash table.
Type: Microsoft.Graph.PowerShell.Models.IMicrosoftGraphPasswordCredential
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: AddViaIdentityExpanded
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
- Name: AddExpanded
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''The URI for the proxy server to use
Type: System.Uri
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''Credentials for a proxy server to use for the remote call
Type: System.Management.Automation.PSCredential
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''Use the default credentials for the proxy
Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''Optional Response Headers Variable.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases:
- RHV
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''The unique identifier of servicePrincipal
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: AddExpanded
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
- Name: Add
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''Runs the command in a mode that only reports what would happen without performing the actions.
Type: System.Management.Automation.SwitchParameter
DefaultValue: ''
SupportsWildcards: false
Aliases:
- wi
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''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.
{{ Fill in the Description }}
Microsoft.Graph.PowerShell.Models.IPathsIeboplServiceprincipalsServiceprincipalIdMicrosoftGraphAddpasswordPostRequestbodyContentApplicationJsonSchema
{{ Fill in the Description }}
{{ Fill in the Description }}
{{ Fill in the Description }}
COMPLEX PARAMETER PROPERTIES
To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.
BODYPARAMETER <IPathsIeboplServiceprincipalsServiceprincipalIdMicrosoftGraphAddpasswordPostRequestbodyContentApplicationJsonSchema>: .
[(Any) ]: This indicates any property can be added to this object.
[PasswordCredential ]: passwordCredential
[(Any) ]: This indicates any property can be added to this object.
[CustomKeyIdentifier <Byte[]>]: Do not use.
[DisplayName ]: Friendly name for the password.
Optional.
[EndDateTime <DateTime?>]: The date and time at which the password expires represented using ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z.
Optional.
[Hint ]: Contains the first three characters of the password.
Read-only.
[KeyId ]: The unique identifier for the password.
[SecretText ]: Read-only; Contains the strong passwords generated by Microsoft Entra ID that are 16-64 characters in length.
The generated password value is only returned during the initial POST request to addPassword.
There is no way to retrieve this password in the future.
[StartDateTime <DateTime?>]: The date and time at which the password becomes valid.
The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z.
Optional.
INPUTOBJECT <IApplicationsIdentity>: Identity Parameter
[AppId ]: Alternate key of application
[AppManagementPolicyId ]: The unique identifier of appManagementPolicy
[AppRoleAssignmentId ]: The unique identifier of appRoleAssignment
[ApplicationId ]: The unique identifier of application
[ApplicationTemplateId ]: The unique identifier of applicationTemplate
[ClaimsMappingPolicyId ]: The unique identifier of claimsMappingPolicy
[DelegatedPermissionClassificationId ]: The unique identifier of delegatedPermissionClassification
[DirectoryDefinitionId ]: The unique identifier of directoryDefinition
[DirectoryObjectId ]: The unique identifier of directoryObject
[EndpointId ]: The unique identifier of endpoint
[ExtensionPropertyId ]: The unique identifier of extensionProperty
[FederatedIdentityCredentialId ]: The unique identifier of federatedIdentityCredential
[GroupId ]: The unique identifier of group
[HomeRealmDiscoveryPolicyId ]: The unique identifier of homeRealmDiscoveryPolicy
[Name ]: Alternate key of federatedIdentityCredential
[OAuth2PermissionGrantId ]: The unique identifier of oAuth2PermissionGrant
[ServicePrincipalId ]: The unique identifier of servicePrincipal
[SynchronizationJobId ]: The unique identifier of synchronizationJob
[SynchronizationTemplateId ]: The unique identifier of synchronizationTemplate
[TargetDeviceGroupId ]: The unique identifier of targetDeviceGroup
[TokenIssuancePolicyId ]: The unique identifier of tokenIssuancePolicy
[TokenLifetimePolicyId ]: The unique identifier of tokenLifetimePolicy
[UniqueName ]: Alternate key of application
[UserId ]: The unique identifier of user
PASSWORDCREDENTIAL <IMicrosoftGraphPasswordCredential>: passwordCredential
[(Any) ]: This indicates any property can be added to this object.
[CustomKeyIdentifier <Byte[]>]: Do not use.
[DisplayName ]: Friendly name for the password.
Optional.
[EndDateTime <DateTime?>]: The date and time at which the password expires represented using ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z.
Optional.
[Hint ]: Contains the first three characters of the password.
Read-only.
[KeyId ]: The unique identifier for the password.
[SecretText ]: Read-only; Contains the strong passwords generated by Microsoft Entra ID that are 16-64 characters in length.
The generated password value is only returned during the initial POST request to addPassword.
There is no way to retrieve this password in the future.
[StartDateTime <DateTime?>]: The date and time at which the password becomes valid.
The Timestamp type represents date and time information using ISO 8601 format and is always in UTC time.
For example, midnight UTC on Jan 1, 2014 is 2014-01-01T00:00:00Z.
Optional.