diff --git a/src/Resources/Resources.Test/Resources.Test.csproj b/src/Resources/Resources.Test/Resources.Test.csproj index 5ec33b256a43..bd295cc33e72 100644 --- a/src/Resources/Resources.Test/Resources.Test.csproj +++ b/src/Resources/Resources.Test/Resources.Test.csproj @@ -11,7 +11,6 @@ - diff --git a/src/Resources/Resources.Test/ScenarioTests/ActiveDirectoryTests.cs b/src/Resources/Resources.Test/ScenarioTests/ActiveDirectoryTests.cs deleted file mode 100644 index 0f23f6816a35..000000000000 --- a/src/Resources/Resources.Test/ScenarioTests/ActiveDirectoryTests.cs +++ /dev/null @@ -1,761 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System.Reflection; -using Microsoft.Azure.Graph.RBAC; -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.Azure.ServiceManagement.Common.Models; -using Microsoft.Rest.ClientRuntime.Azure.TestFramework; -using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Xunit; -using Xunit.Abstractions; - -namespace Microsoft.Azure.Commands.Resources.Test.ScenarioTests -{ - public class ActiveDirectoryTests : ResourceTestRunner - { - XunitTracingInterceptor interceptor { get; set; } - - public ActiveDirectoryTests(ITestOutputHelper output) : base(output) - { - interceptor = new XunitTracingInterceptor(output); - XunitTracingInterceptor.AddToContext(interceptor); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetAllADGroups() - { - const string scriptMethod = "Test-GetAllADGroups"; - ADGroup newGroup = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newGroup = CreateNewAdGroup(controllerAdmin); - return new[] { scriptMethod }; - }, - // cleanup - () => - { - DeleteAdGroup(controllerAdmin, newGroup); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADGroupWithSearchString() - { - const string scriptMethod = "Test-GetADGroupWithSearchString '{0}'"; - ADGroup newGroup = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newGroup = CreateNewAdGroup(controllerAdmin); - return new[] { string.Format(scriptMethod, newGroup.DisplayName) }; - }, - // cleanup - () => - { - DeleteAdGroup(controllerAdmin, newGroup); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADGroupWithBadSearchString() - { - TestRunner.RunTestScript("Test-GetADGroupWithBadSearchString"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADGroupWithObjectId() - { - const string scriptMethod = "Test-GetADGroupWithObjectId '{0}'"; - ADGroup newGroup = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newGroup = CreateNewAdGroup(controllerAdmin); - return new[] { string.Format(scriptMethod, newGroup.ObjectId) }; - }, - // cleanup - () => - { - DeleteAdGroup(controllerAdmin, newGroup); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADGroupSecurityEnabled() - { - const string scriptMethod = "Test-GetADGroupSecurityEnabled '{0}' '{1}'"; - ADGroup newGroup = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newGroup = CreateNewAdGroup(controllerAdmin); - return new[] { string.Format(scriptMethod, newGroup.ObjectId, newGroup.SecurityEnabled) }; - }, - // cleanup - () => - { - DeleteAdGroup(controllerAdmin, newGroup); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADGroupWithBadObjectId() - { - TestRunner.RunTestScript("Test-GetADGroupWithBadObjectId"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADGroupWithUserObjectId() - { - const string scriptMethod = "Test-GetADGroupWithUserObjectId '{0}'"; - User newUser = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newUser = CreateNewAdUser(controllerAdmin); - return new[] { string.Format(scriptMethod, newUser.ObjectId) }; - }, - // cleanup - () => - { - DeleteAdUser(controllerAdmin, newUser); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADGroupMemberWithGroupObjectId() - { - const string scriptMethod = "Test-GetADGroupMemberWithGroupObjectId '{0}' '{1}' '{2}'"; - User newUser = null; - ADGroup newGroup = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newUser = CreateNewAdUser(controllerAdmin); - newGroup = CreateNewAdGroup(controllerAdmin); - - string memberUrl = string.Format( - "{0}{1}/directoryObjects/{2}", - controllerAdmin.GraphClient.BaseUri.AbsoluteUri, - controllerAdmin.GraphClient.TenantID, - newUser.ObjectId); - - controllerAdmin.GraphClient.Groups.AddMember(newGroup.ObjectId, new GroupAddMemberParameters(memberUrl)); - - return new[] { string.Format(scriptMethod, newGroup.ObjectId, newUser.ObjectId, newUser.DisplayName) }; - }, - // cleanup - () => - { - DeleteAdUser(controllerAdmin, newUser); - DeleteAdGroup(controllerAdmin, newGroup); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADGroupMemberWithBadGroupObjectId() - { - TestRunner.RunTestScript("Test-GetADGroupMemberWithBadGroupObjectId"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADGroupMemberWithUserObjectId() - { - const string scriptMethod = "Test-GetADGroupMemberWithUserObjectId '{0}'"; - User newUser = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newUser = CreateNewAdUser(controllerAdmin); - return new[] { string.Format(scriptMethod, newUser.ObjectId) }; - }, - // cleanup - () => - { - DeleteAdUser(controllerAdmin, newUser); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADGroupMemberFromEmptyGroup() - { - const string scriptMethod = "Test-GetADGroupMemberFromEmptyGroup '{0}'"; - ADGroup newGroup = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newGroup = CreateNewAdGroup(controllerAdmin); - return new[] { string.Format(scriptMethod, newGroup.ObjectId) }; - }, - // cleanup - () => - { - DeleteAdGroup(controllerAdmin, newGroup); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADServicePrincipalWithObjectId() - { - const string scriptMethod = "Test-GetADServicePrincipalWithObjectId '{0}'"; - ServicePrincipal newServicePrincipal = null; - Application app = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - app = CreateNewAdApp(controllerAdmin); - newServicePrincipal = CreateNewAdServicePrincipal(controllerAdmin, app.AppId); - return new[] { string.Format(scriptMethod, newServicePrincipal.ObjectId) }; - }, - // cleanup - () => - { - DeleteAdServicePrincipal(controllerAdmin, newServicePrincipal); - DeleteAdApp(controllerAdmin, app); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADServicePrincipalWithBadObjectId() - { - TestRunner.RunTestScript("Test-GetADServicePrincipalWithBadObjectId"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADServicePrincipalWithUserObjectId() - { - const string scriptMethod = "Test-GetADServicePrincipalWithUserObjectId '{0}'"; - User newUser = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newUser = CreateNewAdUser(controllerAdmin); - return new[] { string.Format(scriptMethod, newUser.ObjectId) }; - }, - // cleanup - () => - { - DeleteAdUser(controllerAdmin, newUser); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADServicePrincipalWithSPN() - { - const string scriptMethod = "Test-GetADServicePrincipalWithSPN '{0}'"; - ServicePrincipal newServicePrincipal = null; - Application app = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - app = CreateNewAdApp(controllerAdmin); - newServicePrincipal = CreateNewAdServicePrincipal(controllerAdmin, app.AppId); - return new[] { string.Format(scriptMethod, newServicePrincipal.ServicePrincipalNames[1]) }; - }, - // cleanup - () => - { - DeleteAdServicePrincipal(controllerAdmin, newServicePrincipal); - DeleteAdApp(controllerAdmin, app); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADServicePrincipalWithBadSPN() - { - TestRunner.RunTestScript("Test-GetADServicePrincipalWithBadSPN"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADServicePrincipalWithSearchString() - { - const string scriptMethod = "Test-GetADServicePrincipalWithSearchString '{0}'"; - ServicePrincipal newServicePrincipal = null; - Application app = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - app = CreateNewAdApp(controllerAdmin); - newServicePrincipal = CreateNewAdServicePrincipal(controllerAdmin, app.AppId); - return new[] { string.Format(scriptMethod, newServicePrincipal.DisplayName) }; - }, - // cleanup - () => - { - DeleteAdServicePrincipal(controllerAdmin, newServicePrincipal); - DeleteAdApp(controllerAdmin, app); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADServicePrincipalWithBadSearchString() - { - TestRunner.RunTestScript("Test-GetADServicePrincipalWithBadSearchString"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetAllADUser() - { - const string scriptMethod = "Test-GetAllADUser"; - User newUser = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newUser = CreateNewAdUser(controllerAdmin); - return new[] { string.Format(scriptMethod) }; - }, - // cleanup - () => - { - DeleteAdUser(controllerAdmin, newUser); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADUserWithObjectId() - { - const string scriptMethod = "Test-GetADUserWithObjectId '{0}'"; - User newUser = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newUser = CreateNewAdUser(controllerAdmin); - return new[] { string.Format(scriptMethod, newUser.ObjectId) }; - }, - // cleanup - () => - { - DeleteAdUser(controllerAdmin, newUser); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADUserWithMail() - { - const string scriptMethod = "Test-GetADUserWithMail '{0}'"; - User newUser = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newUser = CreateNewAdUser(controllerAdmin); - return new[] { string.Format(scriptMethod, newUser.UserPrincipalName) }; - }, - // cleanup - () => - { - DeleteAdUser(controllerAdmin, newUser); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADUserWithBadObjectId() - { - TestRunner.RunTestScript("Test-GetADUserWithBadObjectId"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADUserWithGroupObjectId() - { - const string scriptMethod = "Test-GetADUserWithGroupObjectId '{0}'"; - ADGroup newGroup = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newGroup = CreateNewAdGroup(controllerAdmin); - return new[] { string.Format(scriptMethod, newGroup.ObjectId) }; - }, - // cleanup - () => - { - DeleteAdGroup(controllerAdmin, newGroup); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADUserWithUPN() - { - const string scriptMethod = "Test-GetADUserWithUPN '{0}'"; - User newUser = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newUser = CreateNewAdUser(controllerAdmin); - return new[] { string.Format(scriptMethod, newUser.UserPrincipalName) }; - }, - // cleanup - () => - { - DeleteAdUser(controllerAdmin, newUser); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact(Skip = "Currently not working.")] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADUserWithFPOUPN() - { - TestRunner.RunTestScript("Test-GetADUserWithFPOUPN"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADUserWithBadUPN() - { - TestRunner.RunTestScript("Test-GetADUserWithBadUPN"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADUserWithSearchString() - { - const string scriptMethod = "Test-GetADUserWithSearchString '{0}'"; - User newUser = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - newUser = CreateNewAdUser(controllerAdmin); - return new[] { string.Format(scriptMethod, newUser.DisplayName) }; - }, - // cleanup - () => - { - DeleteAdUser(controllerAdmin, newUser); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestGetADUserWithBadSearchString() - { - TestRunner.RunTestScript("Test-GetADUserWithBadSearchString"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestNewADApplication() - { - TestRunner.RunTestScript("Test-NewADApplication"); - } - - [Fact(Skip = "Currently not working.")] - public void TestNewADServicePrincipalWithoutApp() - { - TestRunner.RunTestScript("Test-NewADServicePrincipalWithoutApp"); - } - - [Fact]// (Skip = "Test indicates Graph call is not recorded when it actually is, refer to https://github.com/Azure/azure-powershell/issues/14632 for more details, test passes in record mode")] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestNewADServicePrincipalWithReaderRole() - { - TestRunner.RunTestScript("Test-NewADServicePrincipalWithReaderRole"); - } - - [Fact(Skip = "Currently not working.")] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestNewADServicePrincipalWithCustomScope() - { - TestRunner.RunTestScript("Test-NewADServicePrincipalWithCustomScope"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.LiveOnly)] // Because the role assignment id gets generated randomly during runtime this must be tested in playback mode - public void TestNewADServicePrincipalWithBadScope() - { - TestRunner.RunTestScript("Test-NewADServicePrincipalWithBadScope"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestCreateDeleteAppCredentials() - { - TestRunner.RunTestScript("Test-CreateDeleteAppCredentials"); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestCreateDeleteSpCredentials() - { - const string scriptMethod = "Test-CreateDeleteSpCredentials '{0}'"; - Application application = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - application = CreateNewAdApp(controllerAdmin); - return new[] { string.Format(scriptMethod, application.AppId) }; - }, - // cleanup - () => - { - DeleteAdApp(controllerAdmin, application); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestNewADServicePrincipal() - { - const string scriptMethod = "Test-NewADServicePrincipal '{0}'"; - Application application = null; - var controllerAdmin = ResourcesController.NewInstance; - - controllerAdmin.RunPsTestWorkflow( - interceptor, - // scriptBuilder - () => - { - application = CreateNewAdApp(controllerAdmin); - return new[] { string.Format(scriptMethod, application.AppId) }; - }, - // cleanup - () => - { - DeleteAdApp(controllerAdmin, application); - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name); - } - - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void TestRemoveServicePrincipalWithNameNotFound() - { - TestRunner.RunTestScript("Test-RemoveServicePrincipalWithNameNotFound"); - } - - private User CreateNewAdUser(ResourcesController controllerAdmin) - { - var name = TestUtilities.GenerateName("aduser"); - var parameter = new UserCreateParameters - { - DisplayName = name, - UserPrincipalName = name + "@" + controllerAdmin.UserDomain, - AccountEnabled = true, - MailNickname = name + "test", - PasswordProfile = new PasswordProfile - { - ForceChangePasswordNextLogin = false, - Password = TestUtilities.GenerateName("adpass") + "0#$" - } - }; - - return controllerAdmin.GraphClient.Users.Create(parameter); - } - - private ADGroup CreateNewAdGroup(ResourcesController controllerAdmin) - { - var parameter = new GroupCreateParameters - { - DisplayName = TestUtilities.GenerateName("adgroup"), - MailNickname = TestUtilities.GenerateName("adgroupmail") - }; - return controllerAdmin.GraphClient.Groups.Create(parameter); - } - - private Application CreateNewAdApp(ResourcesController controllerAdmin) - { - var appName = TestUtilities.GenerateName("adApplication"); - var url = string.Format("http://{0}/home", appName); - var appParam = new ApplicationCreateParameters - { - AvailableToOtherTenants = false, - DisplayName = appName, - Homepage = url, - IdentifierUris = new[] { url }, - ReplyUrls = new[] { url } - }; - - return controllerAdmin.GraphClient.Applications.Create(appParam); - } - - private ServicePrincipal CreateNewAdServicePrincipal(ResourcesController controllerAdmin, string appId) - { - var spParam = new ServicePrincipalCreateParameters - { - AppId = appId, - AccountEnabled = true.ToString() - }; - - return controllerAdmin.GraphClient.ServicePrincipals.Create(spParam); - } - - private void DeleteAdUser(ResourcesController controllerAdmin, User user) - { - if (user != null) - { - controllerAdmin.GraphClient.Users.Delete(user.ObjectId); - } - } - private void DeleteAdGroup(ResourcesController controllerAdmin, ADGroup group) - { - if (group != null) - { - controllerAdmin.GraphClient.Groups.Delete(group.ObjectId); - } - } - private void DeleteAdApp(ResourcesController controllerAdmin, Application app) - { - if (app != null) - { - controllerAdmin.GraphClient.Applications.Delete(app.ObjectId); - } - } - - private void DeleteAdServicePrincipal(ResourcesController controllerAdmin, ServicePrincipal newServicePrincipal) - { - if (newServicePrincipal != null) - { - controllerAdmin.GraphClient.ServicePrincipals.Delete(newServicePrincipal.ObjectId); - } - } - } -} \ No newline at end of file diff --git a/src/Resources/Resources.Test/ScenarioTests/ActiveDirectoryTests.ps1 b/src/Resources/Resources.Test/ScenarioTests/ActiveDirectoryTests.ps1 deleted file mode 100644 index 2219490c0379..000000000000 --- a/src/Resources/Resources.Test/ScenarioTests/ActiveDirectoryTests.ps1 +++ /dev/null @@ -1,920 +0,0 @@ -# ---------------------------------------------------------------------------------- -# -# Copyright Microsoft Corporation -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# http://www.apache.org/licenses/LICENSE-2.0 -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------------- - -<# -.SYNOPSIS -Tests getting Active Directory groups. -#> -function Test-GetAllADGroups -{ - # Test - $groups = Get-AzADGroup - - # Assert - Assert-NotNull($groups) - foreach($group in $groups) { - Assert-NotNull($group.DisplayName) - Assert-NotNull($group.Id) - } -} - -<# -.SYNOPSIS -Tests getting Active Directory groups. -#> -function Test-GetADGroupWithSearchString -{ - param([string]$displayName) - - # Test - # Select at most 10 groups. Groups are restricted to contain "test" to fasten the test - $groups = Get-AzADGroup -SearchString $displayName - - # Assert - Assert-AreEqual $groups.Count 1 - Assert-NotNull $groups[0].Id - Assert-AreEqual $groups[0].DisplayName $displayName -} - -<# -.SYNOPSIS -Tests getting Active Directory groups. -#> -function Test-GetADGroupWithBadSearchString -{ - # Test - # Select at most 10 groups. Groups are restricted to contain "test" to fasten the test - $groups = Get-AzADGroup -SearchString "BadSearchString" - - # Assert - Assert-Null($groups) -} - -<# -.SYNOPSIS -Tests getting Active Directory groups. -#> -function Test-GetADGroupWithObjectId -{ - param([string]$objectId) - - # Test - $groups = Get-AzADGroup -ObjectId $objectId - - # Assert - Assert-AreEqual $groups.Count 1 - Assert-AreEqual $groups[0].Id $objectId - Assert-NotNull($groups[0].DisplayName) -} - -<# -.SYNOPSIS -Tests getting Active Directory group with security enabled . -#> -function Test-GetADGroupSecurityEnabled -{ - param([string]$objectId, [string]$securityEnabled) - - # Test - $groups = Get-AzADGroup -ObjectId $objectId - - # Assert - Assert-AreEqual $groups.Count 1 - Assert-AreEqual $groups[0].Id $objectId - Assert-AreEqual $groups[0].SecurityEnabled $securityEnabled - Assert-NotNull($groups[0].DisplayName) -} - -<# -.SYNOPSIS -Tests getting Active Directory groups. -#> -function Test-GetADGroupWithBadObjectId -{ - # Test - $groups = Get-AzADGroup -ObjectId "baadc0de-baad-c0de-baad-c0debaadc0de" - - # Assert - Assert-Null $groups -} - -<# -.SYNOPSIS -Tests getting Active Directory groups. -#> -function Test-GetADGroupWithUserObjectId -{ - param([string]$objectId) - - # Test - $groups = Get-AzADGroup -ObjectId $objectId - - # Assert - Assert-Null $groups -} - -<# -.SYNOPSIS -Tests getting members from an Active Directory group. -#> -function Test-GetADGroupMemberWithGroupObjectId -{ - param([string]$groupObjectId, [string]$userObjectId, [string]$userName) - - # Test - $members = Get-AzADGroupMember -GroupObjectId $groupObjectId - - # Assert - Assert-AreEqual $members.Count 1 - Assert-AreEqual $members[0].Id $userObjectId - Assert-AreEqual $members[0].DisplayName $userName -} - -<# -.SYNOPSIS -Tests getting members from an Active Directory group. -#> -function Test-GetADGroupMemberWithBadGroupObjectId -{ - # Test - Assert-Throws { Get-AzADGroupMember -GroupObjectId "baadc0de-baad-c0de-baad-c0debaadc0de" } -} - -<# -.SYNOPSIS -Tests getting members from an Active Directory group. -#> -function Test-GetADGroupMemberWithUserObjectId -{ - param([string]$objectId) - - # Test - Assert-Throws { Get-AzADGroupMember -GroupObjectId $objectId } -} - -<# -.SYNOPSIS -Tests getting members from an Active Directory group. -#> -function Test-GetADGroupMemberFromEmptyGroup -{ - param([string]$objectId) - - # Test - $members = Get-AzADGroupMember -GroupObjectId $objectId - - # Assert - Assert-Null($members) -} - -<# -.SYNOPSIS -Tests getting Active Directory service principals. -#> -function Test-GetADServicePrincipalWithObjectId -{ - param([string]$objectId) - - # Test - $servicePrincipals = Get-AzADServicePrincipal -ObjectId $objectId - - # Assert - Assert-AreEqual $servicePrincipals.Count 1 - Assert-AreEqual $servicePrincipals[0].Id $objectId -} - -<# -.SYNOPSIS -Tests getting Active Directory service principals. -#> -function Test-GetADServicePrincipalWithBadObjectId -{ - # Test - $servicePrincipals = Get-AzADServicePrincipal -ObjectId "baadc0de-baad-c0de-baad-c0debaadc0de" - - # Assert - Assert-Null($servicePrincipals) -} - -<# -.SYNOPSIS -Tests getting Active Directory service principals. -#> -function Test-GetADServicePrincipalWithUserObjectId -{ - param([string]$objectId) - - # Test - $servicePrincipals = Get-AzADServicePrincipal -ObjectId $objectId - - # Assert - Assert-Null($servicePrincipals) -} - -<# -.SYNOPSIS -Tests getting Active Directory service principals. -#> -function Test-GetADServicePrincipalWithSPN -{ - param([string]$SPN) - - # Test - $servicePrincipals = Get-AzADServicePrincipal -ServicePrincipalName $SPN - - # Assert - Assert-AreEqual $servicePrincipals.Count 1 - Assert-NotNull $servicePrincipals[0].Id - Assert-True { $servicePrincipals[0].ServicePrincipalNames.Contains($SPN) } -} - -<# -.SYNOPSIS -Tests getting Active Directory service principals. -#> -function Test-GetADServicePrincipalWithBadSPN -{ - # Test - $servicePrincipals = Get-AzADServicePrincipal -ServicePrincipalName "badspn" - - # Assert - Assert-Null($servicePrincipals) -} - -<# -.SYNOPSIS -Tests getting Active Directory service principals. -#> -function Test-GetADServicePrincipalWithSearchString -{ - param([string]$displayName) - - # Test - $servicePrincipals = Get-AzADServicePrincipal -SearchString $displayName - - # Assert - Assert-AreEqual $servicePrincipals.Count 1 - Assert-AreEqual $servicePrincipals[0].DisplayName $displayName - Assert-NotNull($servicePrincipals[0].Id) - Assert-NotNull($servicePrincipals[0].ServicePrincipalNames) - Assert-AreEqual $servicePrincipals[0].ServicePrincipalNames.Count 2 -} - -<# -.SYNOPSIS -Tests getting Active Directory service principals. -#> -function Test-GetADServicePrincipalWithBadSearchString -{ - # Test - $servicePrincipals = Get-AzADServicePrincipal -SearchString "badsearchstring" - - # Assert - Assert-Null($servicePrincipals) -} - -<# -.SYNOPSIS -Tests getting Active Directory users. -#> -function Test-GetAllADUser -{ - # Test - $users = Get-AzADUser - - # Assert - Assert-NotNull($users) - foreach($user in $users) { - Assert-NotNull($user.DisplayName) - Assert-NotNull($user.Id) - } -} - -<# -.SYNOPSIS -Tests getting Active Directory users. -#> -function Test-GetADUserWithObjectId -{ - param([string]$objectId) - - # Test - $users = Get-AzADUser -ObjectId $objectId - - # Assert - Assert-AreEqual $users.Count 1 - Assert-AreEqual $users[0].Id $objectId - Assert-NotNull($users[0].DisplayName) - Assert-NotNull($users[0].UserPrincipalName) -} - - -<# -.SYNOPSIS -Tests getting Active Directory users by mail. -#> -function Test-GetADUserWithMail -{ - param([string]$mail) - - # Test - $users = Get-AzADUser -Mail $mail - - # Assert - Assert-AreEqual $users.Count 1 - #Assert-AreEqual $users[0].Mail $mail - Assert-NotNull($users[0].DisplayName) - Assert-NotNull($users[0].UserPrincipalName) -} - -<# -.SYNOPSIS -Tests getting Active Directory users. -#> -function Test-GetADUserWithBadObjectId -{ - # Test - $users = Get-AzADUser -ObjectId "baadc0de-baad-c0de-baad-c0debaadc0de" - - # Assert - Assert-Null($users) -} - -<# -.SYNOPSIS -Tests getting Active Directory users. -#> -function Test-GetADUserWithGroupObjectId -{ - param([string]$objectId) - - # Test - $users = Get-AzADUser -ObjectId $objectId - - # Assert - Assert-Null($users) -} - -<# -.SYNOPSIS -Tests getting Active Directory users. -#> -function Test-GetADUserWithUPN -{ - param([string]$UPN) - - # Test - $users = Get-AzADUser -UserPrincipalName $UPN - - # Assert - Assert-AreEqual $users.Count 1 - Assert-AreEqual $users[0].UserPrincipalName $UPN - Assert-NotNull($users[0].DisplayName) - Assert-NotNull($users[0].Id) -} - -<# -.SYNOPSIS -Tests getting Active Directory users. -#> -function Test-GetADUserWithFPOUPN -{ - # Test - $users = Get-AzADUser -UserPrincipalName "azsdkposhteam_outlook.com#EXT#@rbactest.onmicrosoft.com" - - # Assert - Assert-AreEqual $users.Count 1 - Assert-AreEqual $users[0].UserPrincipalName "azsdkposhteam_outlook.com#EXT#@rbactest.onmicrosoft.com" - Assert-NotNull($users[0].DisplayName) - Assert-NotNull($users[0].Id) -} - -<# -.SYNOPSIS -Tests getting Active Directory users. -#> -function Test-GetADUserWithBadUPN -{ - # Test - $users = Get-AzADUser -UserPrincipalName "baduser@rbactest.onmicrosoft.com" - - # Assert - Assert-Null($users) -} - -<# -.SYNOPSIS -Tests getting Active Directory users. -#> -function Test-GetADUserWithSearchString -{ - param([string]$displayName) - - # Test - # Select at most 10 users. Users are restricted to contain "test" to fasten the test - $users = Get-AzADUser -SearchString $displayName - - # Assert - Assert-NotNull($users) - Assert-AreEqual $users[0].DisplayName $displayName - Assert-NotNull($users[0].Id) - Assert-NotNull($users[0].UserPrincipalName) -} - -<# -.SYNOPSIS -Tests getting Active Directory users. -#> -function Test-GetADUserWithBadSearchString -{ - # Test - # Select at most 10 users. Users are restricted to contain "test" to fasten the test - $users = Get-AzADUser -SearchString "badsearchstring" - - # Assert - Assert-Null($users) -} - -<# -.SYNOPSIS -Tests Creating and deleting application. -#> -function Test-NewADApplication -{ - # Setup - $displayName = getAssetName - $homePage = "http://" + $displayName + ".com" - $identifierUri = "http://" + $displayName - - # Test - $application = New-AzADApplication -DisplayName $displayName -HomePage $homePage -IdentifierUris $identifierUri - - # Assert - Assert-NotNull $application - $apps = Get-AzADApplication - Assert-NotNull $apps - Assert-True { $apps.Count -ge 0 } - - # Get Application by ObjectId - $app1 = Get-AzADApplication -ObjectId $application.ObjectId - Assert-NotNull $app1 - Assert-AreEqual $app1.Count 1 - - # Get Application by ApplicationId - $app1 = Get-AzADApplication -ApplicationId $application.ApplicationId - Assert-NotNull $app1 - Assert-AreEqual $app1.Count 1 - - # Get Application by IdentifierUri - $app1 = Get-AzADApplication -IdentifierUri $application.IdentifierUris[0] - Assert-NotNull $app1 - Assert-AreEqual $app1.Count 1 - - # Get Application by DisplayName - $app1 = Get-AzADApplication -DisplayNameStartWith $application.DisplayName - Assert-NotNull $app1 - Assert-True { $app1.Count -ge 1} - - $newDisplayName = getAssetName - $newHomePage = "http://" + $newDisplayName + ".com" - $newIdentifierUri = "http://" + $newDisplayName - - # Update displayName and HomePage - Set-AzADApplication -ObjectId $application.ObjectId -DisplayName $newDisplayName -HomePage $newHomePage - - # Update identifierUri - Set-AzADApplication -ApplicationId $application.ApplicationId -IdentifierUris $newIdentifierUri - - # Get application and verify updated properties - $app1 = Get-AzADApplication -ObjectId $application.ObjectId - Assert-NotNull $app1 - Assert-AreEqual $app1.Count 1 - Assert-AreEqual $app1.DisplayName $newDisplayName - Assert-AreEqual $app1.HomePage $newHomePage - Assert-AreEqual $app1.IdentifierUris[0] $newIdentifierUri - - # Delete - Remove-AzADApplication -ObjectId $application.ObjectId -Force -} - -<# -.SYNOPSIS -Tests Creating and deleting service principal. -#> -function Test-NewADServicePrincipal -{ - param([string]$applicationId) - - # Test - $servicePrincipal = New-AzADServicePrincipal -ApplicationId $applicationId - - # Assert - Assert-NotNull $servicePrincipal - Assert-Null $servicePrincipal.Secret - - #Verify credential - $cred = Get-AzADSpCredential -ObjectId $servicePrincipal.Id - Assert-Null $cred - - # GetServicePrincipal by ObjectId - $sp1 = Get-AzADServicePrincipal -ObjectId $servicePrincipal.Id - Assert-NotNull $sp1 - Assert-AreEqual $sp1.Count 1 - Assert-AreEqual $sp1.Id $servicePrincipal.Id - - # GetServicePrincipal by SPN - $sp1 = Get-AzADServicePrincipal -ServicePrincipalName $servicePrincipal.ServicePrincipalNames[0] - Assert-NotNull $sp1 - Assert-AreEqual $sp1.Count 1 - Assert-True { $sp1.ServicePrincipalNames.Contains($servicePrincipal.ServicePrincipalNames[0]) } - - # Delete SP - Remove-AzADServicePrincipal -ObjectId $servicePrincipal.Id -Force -} - -<# -.SYNOPSIS -Tests Creating and deleting service principal without an existing application. -#> -function Test-NewADServicePrincipalWithoutApp -{ - # Setup - $displayName = getAssetName - - # Test - $servicePrincipal = New-AzADServicePrincipal -DisplayName $displayName - $role = Get-AzRoleAssignment -ObjectId $servicePrincipal.Id - - # Assert - Assert-NotNull $servicePrincipal - Assert-AreEqual $servicePrincipal.DisplayName $displayName - Assert-Null $role - - # GetServicePrincipal by ObjectId - $sp1 = Get-AzADServicePrincipal -ObjectId $servicePrincipal.Id - Assert-NotNull $sp1 - Assert-AreEqual $sp1.Count 1 - Assert-AreEqual $sp1.Id $servicePrincipal.Id - - # GetServicePrincipal by SPN - $sp1 = Get-AzADServicePrincipal -ServicePrincipalName $servicePrincipal.ServicePrincipalNames[0] - Assert-NotNull $sp1 - Assert-AreEqual $sp1.Count 1 - Assert-True { $sp1.ServicePrincipalNames.Contains($servicePrincipal.ServicePrincipalNames[0]) } - - # Get Application by ApplicationId - $app1 = Get-AzADApplication -ApplicationId $servicePrincipal.ApplicationId - Assert-NotNull $app1 - Assert-AreEqual $app1.Count 1 - - # update SP displayName - $newDisplayName = getAssetName - - Set-AzADServicePrincipal -ObjectId $servicePrincipal.Id -DisplayName $newDisplayName - - # Get SP and verify updated name - $sp1 = Get-AzADServicePrincipal -ObjectId $servicePrincipal.Id - Assert-NotNull $sp1 - Assert-AreEqual $sp1.Count 1 - Assert-AreEqual $sp1.DisplayName $newDisplayName - - # Remove App should delete SP also - Remove-AzADApplication -ObjectId $app1.ObjectId -Force - - Assert-Throws { Remove-AzADServicePrincipal -ObjectId $servicePrincipal.Id -Force} -} - -<# -.SYNOPSIS -Tests creating a service principal with reader permissions -#> -function Test-NewADServicePrincipalWithReaderRole -{ - # Setup - $displayName = getAssetName - $roleDefinitionName = "Reader" - - # Test - $servicePrincipal = New-AzADServicePrincipal -DisplayName $displayName -Role $roleDefinitionName - Assert-NotNull $servicePrincipal - Assert-AreEqual $servicePrincipal.DisplayName $displayName - Assert-NotNull $servicePrincipal.Secret - - #Verify credential - $cred = Get-AzADSpCredential -ObjectId $servicePrincipal.Id - Assert-Null $cred - $cred = Get-AzADAppCredential -ApplicationId $servicePrincipal.ApplicationId - Assert-AreEqual $cred.Count 1 - - try - { - $role = Get-AzRoleAssignment -ObjectId $servicePrincipal.Id - Assert-AreEqual $role.Count 1 - Assert-AreEqual $role.DisplayName $servicePrincipal.DisplayName - Assert-AreEqual $role.ObjectId $servicePrincipal.Id - Assert-AreEqual $role.RoleDefinitionName $roleDefinitionName - Assert-AreEqual $role.ObjectType "ServicePrincipal" - } - finally - { - Remove-AzADApplication -ApplicationId $servicePrincipal.ApplicationId -Force - Remove-AzRoleAssignment -ObjectId $servicePrincipal.Id -RoleDefinitionName $roleDefinitionName - } -} - -<# -.SYNOPSIS -Tests creating a service principal with permissions over a custom scope -#> -function Test-NewADServicePrincipalWithCustomScope -{ - # Setup - $displayName = getAssetName - $defaultRoleDefinitionName = "Contributor" - $subscription = Get-AzSubscription | Select -Last 1 -Wait - $resourceGroup = Get-AzResourceGroup | Select -Last 1 -Wait - $scope = "/subscriptions/" + $subscription.Id + "/resourceGroups/" + $resourceGroup.ResourceGroupName - - # Test - $servicePrincipal = New-AzADServicePrincipal -DisplayName $displayName -Scope $scope - Assert-NotNull $servicePrincipal - Assert-AreEqual $servicePrincipal.DisplayName $displayName - Assert-NotNull $servicePrincipal.Secret - - #Verify credential - $cred = Get-AzADSpCredential -ObjectId $servicePrincipal.Id - Assert-Null $cred - $cred = Get-AzADAppCredential -ApplicationId $servicePrincipal.ApplicationId - Assert-AreEqual $cred.Count 1 - - try - { - $role = Get-AzRoleAssignment -ObjectId $servicePrincipal.Id - Assert-AreEqual $role.Count 1 - Assert-AreEqual $role.DisplayName $servicePrincipal.DisplayName - Assert-AreEqual $role.ObjectId $servicePrincipal.Id - Assert-AreEqual $role.RoleDefinitionName $defaultRoleDefinitionName - Assert-AreEqual $role.Scope $scope - Assert-AreEqual $role.ObjectType "ServicePrincipal" - } - finally - { - Remove-AzADApplication -ApplicationId $servicePrincipal.ApplicationId -Force - Remove-AzRoleAssignment -ObjectId $servicePrincipal.Id -Scope $scope -RoleDefinitionName $defaultRoleDefinitionName - } -} - -<# -.SYNOPSIS -Tests creating a service principal with permissions over a non existant scope -#> -function Test-NewADServicePrincipalWithBadScope -{ - -#"Resource group 'totallyRealScopeThatCanTotallyExistAndThisTestWillNeverEverCollide' could not be found." -#This means the role assignment was not able to be created. Please assign a role manually with help of the Service Principal Id - - - - # Setup - $displayName = "IfYouSeeThisCleanupWentWrongDeleteOnSight" - $defaultRoleDefinitionName = "Reader" - $subscription = Get-AzSubscription | Select -Last 1 -Wait - $resourceGroup = "totallyRealScopeThatCanTotallyExistAndThisTestWillNeverEverCollide" - $scope = "/subscriptions/" + $subscription.Id + "/resourceGroups/" + $resourceGroup - - # Test - try - { - Assert-ThrowsContains { New-AzADServicePrincipal -DisplayName $displayName -Scope $scope -Role $defaultRoleDefinitionName} "Please assign a role manually" - } - finally - { - $servicePrincipal = Get-AzADServicePrincipal -DisplayName $displayName - Remove-AzADApplication -ApplicationId $servicePrincipal.ApplicationId -Force - } -} - -<# -.SYNOPSIS -Tests Creating and deleting application using App Credentials. -#> -function Test-CreateDeleteAppCredentials -{ - # Setup - $getAssetName = ConvertTo-SecureString "test" -AsPlainText -Force - $displayName = "test" - $identifierUri = "http://" + $displayName - $password = $getAssetName - $keyId1 = "316af45c-83ff-42a5-a1d1-8fe9b2de3ac1" - $keyId2 = "9b7fda23-cb39-4504-8aa6-3570c4239620" - $keyId3 = "4141b479-4ca0-4919-8451-7e155de6aa0f" - - # Test - Add application with a password cred - $application = New-AzADApplication -DisplayName $displayName -IdentifierUris $identifierUri -Password $password - - # Assert - Assert-NotNull $application - Try { - # Get Application by ObjectId - $app1 = Get-AzADApplication -ObjectId $application.ObjectId - Assert-NotNull $app1 - - # Get credential should fetch 1 credential - $cred1 = Get-AzADAppCredential -ObjectId $application.ObjectId - Assert-NotNull $cred1 - Assert-AreEqual $cred1.Count 1 - - # Add 1 more password credential to the same app - $start = (Get-Date).ToUniversalTime() - $end = $start.AddYears(1) - $cred = New-AzADAppCredentialWithId -ObjectId $application.ObjectId -Password $password -StartDate $start -EndDate $end -KeyId $keyId1 - Assert-NotNull $cred - - # Get credential should fetch 2 credentials - $cred2 = Get-AzADAppCredential -ObjectId $application.ObjectId - Assert-NotNull $cred2 - Assert-AreEqual $cred2.Count 2 - $credCount = $cred2 | where {$_.KeyId -in $cred1.KeyId, $cred.KeyId} - Assert-AreEqual $credCount.Count 2 - $cred2 = $cred - - # Add 1 key credential to the same app - $certPath = Join-Path $ResourcesPath "certificate.pfx" - $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certPath) - - $binCert = $cert.GetRawCertData() - $credValue = [System.Convert]::ToBase64String($binCert) - $start = (Get-Date).ToUniversalTime() - $end = $start.AddDays(1) - $cred = New-AzADAppCredentialWithId -ObjectId $application.ObjectId -CertValue $credValue -StartDate $start -EndDate $end -KeyId $keyId2 - Assert-NotNull $cred - - # Get credential should fetch 3 credentials - $cred3 = Get-AzADAppCredential -ObjectId $application.ObjectId - Assert-NotNull $cred3 - Assert-AreEqual $cred3.Count 3 - $credCount = $cred3 | where {$_.KeyId -in $cred1.KeyId, $cred2.KeyId, $cred.KeyId} - Assert-AreEqual $credCount.Count 3 - $cred3 = $cred - - # Add 1 more key credential to the same app - $binCert = $cert.GetRawCertData() - $credValue = [System.Convert]::ToBase64String($binCert) - $start = (Get-Date).ToUniversalTime() - $end = $start.AddDays(1) - $cred = New-AzADAppCredentialWithId -ObjectId $application.ObjectId -CertValue $credValue -StartDate $start -EndDate $end -KeyId $keyId3 - Assert-NotNull $cred - - # Get credential should fetch 4 credentials - $cred4 = Get-AzADAppCredential -ObjectId $application.ObjectId - Assert-NotNull $cred4 - Assert-AreEqual $cred4.Count 4 - $credCount = $cred4 | where {$_.KeyId -in $cred1.KeyId, $cred2.KeyId, $cred3.KeyId, $cred.KeyId} - Assert-AreEqual $credCount.Count 4 - - # Remove cred by KeyId - Remove-AzADAppCredential -ApplicationId $application.ApplicationId -KeyId $cred.KeyId -Force - $cred5 = Get-AzADAppCredential -ApplicationId $application.ApplicationId - Assert-NotNull $cred5 - Assert-AreEqual $cred5.Count 3 - Assert-AreEqual $cred5[2].KeyId $cred1.KeyId - - # Remove All creds - Remove-AzADAppCredential -ObjectId $application.ObjectId -Force - $cred5 = Get-AzADAppCredential -ObjectId $application.ObjectId - Assert-Null $cred5 - - $newApplication = Get-AzADApplication -DisplayNameStartWith "PowershellTestingApp" - Assert-Throws { New-AzADAppCredential -ApplicationId $newApplication.ApplicationId -Password "Somedummypwd"} - } - Finally{ - # Remove App - Remove-AzADApplication -ObjectId $application.ObjectId -Force - } -} - - -<# -.SYNOPSIS -Tests Creating and deleting application using Service Principal Credentials. -#> -function Test-CreateDeleteSpCredentials -{ - param([string]$applicationId) - - # Setup - $getAssetName = ConvertTo-SecureString "test" -AsPlainText -Force - $displayName = "test" - $identifierUri = "http://" + $displayName - $password = $getAssetName - $keyId1 = "316af45c-83ff-42a5-a1d1-8fe9b2de3ac1" - $keyId2 = "9b7fda23-cb39-4504-8aa6-3570c4239620" - $keyId3 = "4141b479-4ca0-4919-8451-7e155de6aa0f" - - # Test - Add SP - $servicePrincipal = New-AzADServicePrincipal -DisplayName $displayName -ApplicationId $applicationId - - # Assert - Assert-NotNull $servicePrincipal - Assert-Null $servicePrincipal.Secret - - Try - { - # Get service principal by ObjectId - $sp1 = Get-AzADServicePrincipal -ObjectId $servicePrincipal.Id - Assert-NotNull $sp1.Id - - # Get credential should fetch 1 credential - $cred1 = Get-AzADSpCredential -ObjectId $servicePrincipal.Id - Assert-Null $cred1 - - # Add 1 more password credential to the same app - $start = (Get-Date).ToUniversalTime() - $end = $start.AddYears(1) - $cred = New-AzADSpCredentialWithId -ObjectId $servicePrincipal.Id -StartDate $start -EndDate $end -KeyId $keyId1 - Assert-NotNull $cred - - # Get credential should fetch 2 credentials - $cred2 = Get-AzADSpCredential -ObjectId $servicePrincipal.Id - Assert-NotNull $cred2 - Assert-AreEqual $cred2.Count 1 - $credCount = $cred2 | where {$_.KeyId -in $cred1.KeyId, $cred.KeyId} - Assert-AreEqual $credCount.Count 1 - $cred2 = $cred - - # Add 1 key credential to the same app - $certPath = Join-Path $ResourcesPath "certificate.pfx" - $cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2($certPath) - - $binCert = $cert.GetRawCertData() - $credValue = [System.Convert]::ToBase64String($binCert) - $start = (Get-Date).ToUniversalTime() - $end = $start.AddDays(1) - $cred = New-AzADSpCredentialWithId -ObjectId $servicePrincipal.Id -CertValue $credValue -StartDate $start -EndDate $end -KeyId $keyId2 - Assert-NotNull $cred - - # Get credential should fetch 3 credentials - $cred3 = Get-AzADSpCredential -ObjectId $servicePrincipal.Id - Assert-NotNull $cred3 - Assert-AreEqual $cred3.Count 2 - $credCount = $cred3 | where {$_.KeyId -in $cred1.KeyId, $cred2.KeyId, $cred.KeyId} - Assert-AreEqual $credCount.Count 2 - $cred3 = $cred - - # Add 1 more key credential to the same app - $binCert = $cert.GetRawCertData() - $credValue = [System.Convert]::ToBase64String($binCert) - $start = (Get-Date).ToUniversalTime() - $end = $start.AddDays(1) - $cred = New-AzADSpCredentialWithId -ObjectId $servicePrincipal.Id -CertValue $credValue -StartDate $start -EndDate $end -KeyId $keyId3 - Assert-NotNull $cred - - # Get credential should fetch 4 credentials - $cred4 = Get-AzADSpCredential -ObjectId $servicePrincipal.Id - Assert-NotNull $cred4 - Assert-AreEqual $cred4.Count 3 - $credCount = $cred4 | where {$_.KeyId -in $cred1.KeyId, $cred2.KeyId, $cred3.KeyId, $cred.KeyId} - Assert-AreEqual $credCount.Count 3 - - - # Remove cred by KeyId - Remove-AzADSpCredential -ServicePrincipalName $servicePrincipal.ServicePrincipalNames[0] -KeyId $cred.KeyId -Force - $cred5 = Get-AzADSpCredential -ServicePrincipalName $servicePrincipal.ServicePrincipalNames[0] - Assert-NotNull $cred5 - Assert-AreEqual $cred5.Count 2 - Assert-AreEqual $cred5[2].KeyId $cred1.KeyId - - # Remove All creds - Remove-AzADSpCredential -ObjectId $servicePrincipal.Id -Force - $cred5 = Get-AzADSpCredential -ObjectId $servicePrincipal.Id - Assert-Null $cred5 - } - Finally - { - # Remove Service Principal - Remove-AzADServicePrincipal -ObjectId $servicePrincipal.Id -Force - } -} - -<# -.SYNOPSIS -Tests registering and a resource provider feature. -#> -function Test-RemoveServicePrincipalWithNameNotFound -{ - $FakeServicePrincipalName = "this is a fake service principal name and there are no way this can be valid" - - Assert-ThrowsContains {Remove-AzADServicePrincipal -ServicePrincipalName $FakeServicePrincipalName} "Could not find a service principal with the name" -} diff --git a/src/Resources/Resources.Test/ScenarioTests/DenyAssignmentTests.cs b/src/Resources/Resources.Test/ScenarioTests/DenyAssignmentTests.cs index a2885d0dabdb..6ef12edc8b90 100644 --- a/src/Resources/Resources.Test/ScenarioTests/DenyAssignmentTests.cs +++ b/src/Resources/Resources.Test/ScenarioTests/DenyAssignmentTests.cs @@ -31,168 +31,168 @@ public DenyAssignmentTests(ITestOutputHelper output) : base(output) } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDa() { TestRunner.RunTestScript("Test-GetDa"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaById() { TestRunner.RunTestScript("Test-GetDaById"); } - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Fact(Skip = "Name filter issue is detected, refer to: https://github.com/Azure/azure-powershell/issues/16410")] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByIdAndSpecifiedScope() { TestRunner.RunTestScript("Test-GetDaByIdAndSpecifiedScope"); } - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Fact(Skip = "Name filter issue is detected, refer to: https://github.com/Azure/azure-powershell/issues/16410")] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByName() { TestRunner.RunTestScript("Test-GetDaByName"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByNameAndSpecifiedScope() { TestRunner.RunTestScript("Test-GetDaByNameAndSpecifiedScope"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByObjectId() { TestRunner.RunTestScript("Test-GetDaByObjectId"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByObjectIdAndGroupExpansion() { TestRunner.RunTestScript("Test-GetDaByObjectIdAndGroupExpansion"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByObjectIdAndRGName() { TestRunner.RunTestScript("Test-GetDaByObjectIdAndRGName"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByObjectIdAndRGNameResourceNameResourceType() { TestRunner.RunTestScript("Test-GetDaByObjectIdAndRGNameResourceNameResourceType"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByObjectIdAndScope() { TestRunner.RunTestScript("Test-GetDaByObjectIdAndScope"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaBySignInNameAndRGName() { TestRunner.RunTestScript("Test-GetDaBySignInNameAndRGName"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaBySignInNameAndRGNameResourceNameResourceType() { TestRunner.RunTestScript("Test-GetDaBySignInNameAndRGNameResourceNameResourceType"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaBySignInNameAndScope() { TestRunner.RunTestScript("Test-GetDaBySignInNameAndScope"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaBySignInName() { TestRunner.RunTestScript("Test-GetDaBySignInName"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaBySignInNameAndGroupExpansion() { TestRunner.RunTestScript("Test-GetDaBySignInNameAndGroupExpansion"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByServicePrincipalName() { TestRunner.RunTestScript("Test-GetDaByServicePrincipalName"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByServicePrincipalNameAndRGName() { TestRunner.RunTestScript("Test-GetDaByServicePrincipalNameAndRGName"); } - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Fact(Skip = "Skip complex scenario temporarily, will test it when bandwidth is allowed")] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByServicePrincipalNameAndRGNameResourceNameResourceType() { TestRunner.RunTestScript("Test-GetDaByServicePrincipalNameAndRGNameResourceNameResourceType"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByServicePrincipalNameAndScope() { TestRunner.RunTestScript("Test-GetDaByServicePrincipalNameAndScope"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByScope() { TestRunner.RunTestScript("Test-GetDaByScope"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByRG() { TestRunner.RunTestScript("Test-GetDaByRG"); } - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Fact(Skip = "Skip complex scenario temporarily, will test it when bandwidth is allowed")] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByRGNameResourceNameResourceType() { TestRunner.RunTestScript("Test-GetDaByRGNameResourceNameResourceType"); } - [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Fact(Skip = "Name filter issue is detected, refer to: https://github.com/Azure/azure-powershell/issues/16410")] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaForEveryoneHasExpectedNameAndType() { TestRunner.RunTestScript("Test-GetDaForEveryoneHasExpectedNameAndType"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void GetDaByEveryoneObjectId() { TestRunner.RunTestScript("Test-GetDaByEveryoneObjectId"); diff --git a/src/Resources/Resources.Test/ScenarioTests/DenyAssignmentTests.ps1 b/src/Resources/Resources.Test/ScenarioTests/DenyAssignmentTests.ps1 index c2d91a0dd7f3..2d3188021e4f 100644 --- a/src/Resources/Resources.Test/ScenarioTests/DenyAssignmentTests.ps1 +++ b/src/Resources/Resources.Test/ScenarioTests/DenyAssignmentTests.ps1 @@ -29,7 +29,8 @@ function Test-GetDa function Test-GetDaById { - $id = '22704996-fbd0-4ab1-8625-722d897825d2' + # Random select a id from the result of listing deny assignments + $id = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourcegroups/managed-rg-feng-purview/providers/Microsoft.Authorization/denyAssignments/5184754b-6c52-436a-90a5-cae79bfbfea1" $assignments = Get-AzDenyAssignment -Id $id Assert-NotNull $assignments @@ -39,18 +40,18 @@ function Test-GetDaById function Test-GetDaByIdAndSpecifiedScope { - $id = '43AF7D0C-0BF8-407F-96C0-96A29D076431' - $scope = '/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourcegroups/AzureAuthzSDK' + $id = '5184754b-6c52-436a-90a5-cae79bfbfea1' + $scope = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourcegroups/managed-rg-feng-purview" $assignments = Get-AzDenyAssignment -Id $id -Scope $scope Assert-NotNull $assignments Assert-True { $assignments.Length -eq 1 } - Assert-AreEqual $assignments[0].Id $id + Assert-AreEqual $assignments[0].Id "$scope/providers/Microsoft.Authorization/denyAssignments/$id" } function Test-GetDaByName { - $daName = 'AzureAuthzSDK_22704996-FBD0-4AB1-8625-722D897825D2' + $daName = "StoragePool Resource Provider Management Lock for MSP_bez-rg_bez-diskpool_eastus" $assignments = Get-AzDenyAssignment -DenyAssignmentName $daName Assert-NotNull $assignments @@ -60,8 +61,8 @@ function Test-GetDaByName function Test-GetDaByNameAndSpecifiedScope { - $daName = 'AzureAuthzSDK_43AF7D0C-0BF8-407F-96C0-96A29D076431' - $daScope = '/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourcegroups/AzureAuthzSDK' + $daName = "StoragePool Resource Provider Management Lock for MSP_bez-rg_bez-diskpool_eastus" + $daScope = '/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/databricks-rg-demo001-h09oyaz47r6qb' $assignments = Get-AzDenyAssignment -DenyAssignmentName $daName -Scope $daScope Assert-NotNull $assignments @@ -72,7 +73,7 @@ function Test-GetDaByNameAndSpecifiedScope function Test-GetDaByObjectId { - $objectId = 'f8d526a054eb4941ae69ebf4a334d0f0' + $objectId = '00000000-0000-0000-0000-000000000000' $assignments = Get-AzDenyAssignment -ObjectId $objectId Assert-NotNull $assignments @@ -81,7 +82,7 @@ function Test-GetDaByObjectId function Test-GetDaByObjectIdAndGroupExpansion { - $objectId = 'f8d526a054eb4941ae69ebf4a334d0f0' + $objectId = '00000000-0000-0000-0000-000000000000' $assignments = Get-AzDenyAssignment -ObjectId $objectId -ExpandPrincipalGroups Assert-NotNull $assignments @@ -90,8 +91,8 @@ function Test-GetDaByObjectIdAndGroupExpansion function Test-GetDaByObjectIdAndRGName { - $objectId = 'f8d526a054eb4941ae69ebf4a334d0f0' - $resourceGroupName = 'AzureAuthzSDK' + $objectId = '00000000-0000-0000-0000-000000000000' + $resourceGroupName = 'managed-rg-fypurview' $assignments = Get-AzDenyAssignment -ObjectId $objectId -ResourceGroupName $resourceGroupName Assert-NotNull $assignments @@ -100,10 +101,10 @@ function Test-GetDaByObjectIdAndRGName function Test-GetDaByObjectIdAndRGNameResourceNameResourceType { - $objectId = 'f8d526a054eb4941ae69ebf4a334d0f0' - $resourceGroupName = 'AzureAuthzSDK' - $resourceName ='authzsdktestresource' - $resourceType = 'Microsoft.Storage/storageAccounts' + $objectId = '00000000-0000-0000-0000-000000000000' + $resourceGroupName = 'managed-rg-fypurview' + $resourceName ='demo001' + $resourceType = 'Microsoft.Databricks/workspaces' $assignments = Get-AzDenyAssignment -ObjectId $objectId -ResourceGroupName $resourceGroupName -ResourceName $resourceName -ResourceType $resourceType Assert-NotNull $assignments @@ -112,8 +113,8 @@ function Test-GetDaByObjectIdAndRGNameResourceNameResourceType function Test-GetDaByObjectIdAndScope { - $objectId = 'f8d526a054eb4941ae69ebf4a334d0f0' - $scope = '/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourcegroups/AzureAuthzSDK' + $objectId = '00000000-0000-0000-0000-000000000000' + $scope = "/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourcegroups/managed-rg-feng-purview" $assignments = Get-AzDenyAssignment -ObjectId $objectId -Scope $scope Assert-NotNull $assignments @@ -122,7 +123,7 @@ function Test-GetDaByObjectIdAndScope function Test-GetDaBySignInName { - $signInName = 'test2@rbacCliTest.onmicrosoft.com' + $signInName = 'bez@azuresdkteam.onmicrosoft.com' $assignments = Get-AzDenyAssignment -SignInName $signInName Assert-NotNull $assignments @@ -213,7 +214,7 @@ function Test-GetDaByServicePrincipalNameAndScope function Test-GetDaByScope { - $scope = '/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourcegroups/AzureAuthzSDK' + $scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590/resourcegroups/managed-rg-feng-purview' $assignments = Get-AzDenyAssignment -Scope $scope Assert-NotNull $assignments @@ -222,7 +223,7 @@ function Test-GetDaByScope function Test-GetDaByRG { - $resourceGroupName = 'AzureAuthzSDK' + $resourceGroupName = 'managed-rg-feng-purview' $assignments = Get-AzDenyAssignment -ResourceGroupName $resourceGroupName Assert-NotNull $assignments diff --git a/src/Resources/Resources.Test/ScenarioTests/DeploymentTests.cs b/src/Resources/Resources.Test/ScenarioTests/DeploymentTests.cs index 4f3c3bab0f17..918c5cc01c33 100644 --- a/src/Resources/Resources.Test/ScenarioTests/DeploymentTests.cs +++ b/src/Resources/Resources.Test/ScenarioTests/DeploymentTests.cs @@ -124,7 +124,7 @@ public void TestNestedErrorsDisplayed() } [Fact(Skip = "Fix acquisition of TenantId in KeyVault Test.")] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void TestNewDeploymentWithKeyVaultReference() { TestRunner.RunTestScript("Test-NewDeploymentWithKeyVaultReference"); diff --git a/src/Resources/Resources.Test/ScenarioTests/ResourcesController.cs b/src/Resources/Resources.Test/ScenarioTests/ResourcesController.cs index 82dab68d5e57..fc22c6add9f7 100644 --- a/src/Resources/Resources.Test/ScenarioTests/ResourcesController.cs +++ b/src/Resources/Resources.Test/ScenarioTests/ResourcesController.cs @@ -12,20 +12,11 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Threading; -using System.Threading.Tasks; using Microsoft.Azure.Commands.Common.Authentication; using Microsoft.Azure.Commands.Common.Authentication.Abstractions; +using Microsoft.Azure.Commands.Common.MSGraph.Version1_0; using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Components; using Microsoft.Azure.Commands.ResourceManager.Cmdlets.Extensions; -using Microsoft.Azure.Graph.RBAC; using Microsoft.Azure.Management.Authorization; using Microsoft.Azure.Management.ManagementGroups; using Microsoft.Azure.Management.ResourceManager; @@ -34,6 +25,17 @@ using Microsoft.Rest; using Microsoft.Rest.ClientRuntime.Azure.TestFramework; using Microsoft.WindowsAzure.Commands.ScenarioTest; + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Threading; +using System.Threading.Tasks; + using TestEnvironmentFactory = Microsoft.Rest.ClientRuntime.Azure.TestFramework.TestEnvironmentFactory; namespace Microsoft.Azure.Commands.Resources.Test.ScenarioTests @@ -45,7 +47,7 @@ public sealed class ResourcesController private const string DomainKey = "Domain"; private const string SubscriptionIdKey = "SubscriptionId"; - public GraphRbacManagementClient GraphClient { get; private set; } + public MicrosoftGraphClient GraphClient { get; private set; } public ResourceManagementClient ResourceManagementClient { get; private set; } @@ -159,7 +161,7 @@ private void SetupManagementClients(MockContext context) DeploymentScriptsClient); } - private GraphRbacManagementClient GetGraphClient(MockContext context) + private MicrosoftGraphClient GetGraphClient(MockContext context) { var environment = TestEnvironmentFactory.GetTestEnvironment(); string tenantId = null; @@ -188,7 +190,7 @@ private GraphRbacManagementClient GetGraphClient(MockContext context) } } - var client = context.GetGraphServiceClient(environment); + var client = context.GetGraphServiceClient(environment); client.TenantID = tenantId; if (AzureRmProfileProvider.Instance != null && AzureRmProfileProvider.Instance.Profile != null && diff --git a/src/Resources/Resources.Test/ScenarioTests/RoleAssignmentTests.cs b/src/Resources/Resources.Test/ScenarioTests/RoleAssignmentTests.cs index e62d099c00bd..20a4fb64dd4b 100644 --- a/src/Resources/Resources.Test/ScenarioTests/RoleAssignmentTests.cs +++ b/src/Resources/Resources.Test/ScenarioTests/RoleAssignmentTests.cs @@ -13,17 +13,9 @@ // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Graph.RBAC; -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.Azure.Management.Authorization; -using Microsoft.Azure.Management.ResourceManager; -using Microsoft.Azure.Management.ResourceManager.Models; using Microsoft.Azure.ServiceManagement.Common.Models; using Microsoft.WindowsAzure.Commands.ScenarioTest; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System.Linq; -using System.Reflection; -using Microsoft.Rest.ClientRuntime.Azure.TestFramework; + using Xunit; using Xunit.Abstractions; @@ -40,70 +32,70 @@ public RoleAssignmentTests(ITestOutputHelper output) : base(output) } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaClassicAdmins() { TestRunner.RunTestScript("Test-RaClassicAdmins"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaClassicAdminsWithScope() { ResourcesController.NewInstance.RunPsTest(_logger, "Test-RaClassicAdminsWithScope"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaDeletedPrincipals() { TestRunner.RunTestScript("Test-RaDeletedPrincipals"); } - [Fact(Skip = "Test fails during parallelization. Test uses RoleDefinitionNames statically.")] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Fact] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaPropertiesValidation() { TestRunner.RunTestScript("Test-RaPropertiesValidation"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaNegativeScenarios() { TestRunner.RunTestScript("Test-RaNegativeScenarios"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaByScope() { TestRunner.RunTestScript("Test-RaByScope"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaDeleteByPSRoleAssignment() { TestRunner.RunTestScript("Test-RaDeleteByPSRoleAssignment"); } - [Fact]//(Skip = "Test indicates Graph call is not recorded when it actually is, refer to https://github.com/Azure/azure-powershell/issues/14632 for more details, test passes in record mode")] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Fact] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaByResourceGroup() { TestRunner.RunTestScript("Test-RaByResourceGroup"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaByResource() { TestRunner.RunTestScript("Test-RaByResource"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaValidateInputParameters() { TestRunner.RunTestScript("Test-RaValidateInputParameters Get-AzureRmRoleAssignment"); @@ -112,70 +104,70 @@ public void RaValidateInputParameters() } [Fact]//(Skip = "Test indicates Graph call is not recorded when it actually is, refer to https://github.com/Azure/azure-powershell/issues/14632 for more details, test passes in record mode")] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaByServicePrincipal() { TestRunner.RunTestScript("Test-RaByServicePrincipal"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaById() { TestRunner.RunTestScript("Test-RaById"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaDeletionByScope() { TestRunner.RunTestScript("Test-RaDeletionByScope"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaDeletionByScopeAtRootScope() { TestRunner.RunTestScript("Test-RaDeletionByScopeAtRootScope"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaDelegation() { TestRunner.RunTestScript("Test-RaDelegation"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaByUpn() { TestRunner.RunTestScript("Test-RaByUpn"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaGetByScope() { TestRunner.RunTestScript("Test-RaGetByScope"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaGetOnlyByRoleDefinitionName() { TestRunner.RunTestScript("Test-RaGetOnlyByRoleDefinitionName"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaGetByUPNWithExpandPrincipalGroups() { TestRunner.RunTestScript("Test-RaGetByUPNWithExpandPrincipalGroups"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaCreatedBySP() { TestRunner.RunTestScript("Test-RaCreatedBySP"); @@ -189,14 +181,14 @@ public void RaWithV1Conditions() } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaWithV2Conditions() { TestRunner.RunTestScript("Test-RaWithV2Conditions"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void RaWithV2ConditionsOnly() { TestRunner.RunTestScript("Test-RaWithV2ConditionsOnly"); @@ -210,168 +202,52 @@ public void RaWithV2ConditionVersionOnly() } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void UpdateRa() { TestRunner.RunTestScript("Test-UpdateRa"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void CreateRAForGroup() { TestRunner.RunTestScript("Test-CreateRAForGroup"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void CreateRAForGuest() { TestRunner.RunTestScript("Test-CreateRAForGuest"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void CreateRAForMember() { TestRunner.RunTestScript("Test-CreateRAForMember"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void CreateRAForServicePrincipal() { TestRunner.RunTestScript("Test-CreateRAForServicePrincipal"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void CreateRAWhenIdNotExist() { TestRunner.RunTestScript("Test-CreateRAWhenIdNotExist"); } [Fact] - [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.AcceptanceType, Category.LiveOnly)] public void CreateRAWithObjectType() { TestRunner.RunTestScript("Test-CreateRAWithObjectType"); } - - [Fact(Skip = "Fix the flaky test and token error and then re-record the test. Token from admin user is being used even when trying to use newly created user.")] - [Trait(Category.AcceptanceType, Category.CheckIn)] - public void RaUserPermissions() - { - User newUser = null; - ResourceGroup resourceGroup = null; - string roleAssignmentId = "A807281A-2F74-44B9-B862-C0D3683ADCC9"; - string userName = null; - string userPass = null; - string userPermission = "*/read"; - string roleDefinitionName = "Reader"; - string newUserObjectId = null; - - var controllerAdmin = ResourcesController.NewInstance; - - try - { - // Generate new user under admin account - controllerAdmin.RunPsTestWorkflow( - _logger, - // scriptBuilder - () => - { - userName = TestUtilities.GenerateName("aduser"); - userPass = TestUtilities.GenerateName("adpass") + "0#$"; - - var upn = userName + "@" + controllerAdmin.UserDomain; - - var parameter = new UserCreateParameters - { - UserPrincipalName = upn, - DisplayName = userName, - AccountEnabled = true, - MailNickname = userName + "test", - PasswordProfile = new PasswordProfile - { - ForceChangePasswordNextLogin = false, - Password = userPass - } - }; - - newUser = controllerAdmin.GraphClient.Users.Create(parameter); - newUserObjectId = newUser.ObjectId; - - resourceGroup = controllerAdmin.ResourceManagementClient.ResourceGroups - .List() - .First(); - - // Wait to allow newly created object changes to propagate - TestMockSupport.Delay(20000); - - return new[] - { - string.Format( - "CreateRoleAssignment '{0}' '{1}' '{2}' '{3}'", - roleAssignmentId, - newUserObjectId, - roleDefinitionName, - resourceGroup.Name) - }; - }, - // cleanup - null, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name + "_Setup"); - - // login as different user and run the test - var controllerUser = ResourcesController.NewInstance; - controllerUser.RunPsTestWorkflow( - _logger, - // scriptBuilder - () => - { - // Wait to allow for the role assignment to propagate - TestMockSupport.Delay(20000); - - return new[] - { - string.Format( - "Test-RaUserPermissions '{0}' '{1}'", - resourceGroup.Name, - userPermission) - }; - }, - // cleanup - null, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name + "_Test"); - } - finally - { - // remove created user and assignment - controllerAdmin = ResourcesController.NewInstance; - controllerAdmin.RunPsTestWorkflow( - // scriptBuilder - null, - // initialize - null, - // cleanup - () => - { - if (newUser != null) - { - controllerAdmin.GraphClient.Users.Delete(newUser.ObjectId); - } - - if (resourceGroup != null) - { - controllerAdmin.AuthorizationManagementClient.RoleAssignments.Delete(resourceGroup.Id, roleAssignmentId).ToString(); - } - }, - MethodBase.GetCurrentMethod().ReflectedType?.ToString(), - MethodBase.GetCurrentMethod().Name + "_Cleanup"); - } - } } } diff --git a/src/Resources/Resources.Test/ScenarioTests/RoleAssignmentTests.ps1 b/src/Resources/Resources.Test/ScenarioTests/RoleAssignmentTests.ps1 index f201b05ffa7e..f6561adc7cc9 100644 --- a/src/Resources/Resources.Test/ScenarioTests/RoleAssignmentTests.ps1 +++ b/src/Resources/Resources.Test/ScenarioTests/RoleAssignmentTests.ps1 @@ -18,11 +18,8 @@ Tests retrieval of classic administrators #> function Test-RaClassicAdmins { - # Setup - $subscription = $(Get-AzContext).Subscription - # Test - $classic = Get-AzRoleAssignment -IncludeClassicAdministrators | Where-Object { $_.Scope -ieq ('/subscriptions/' + $subscription[0].Id) -and $_.RoleDefinitionName -ieq 'ServiceAdministrator;AccountAdministrator' } + $classic = Get-AzRoleAssignment -IncludeClassicAdministrators # Assert Assert-NotNull $classic @@ -36,17 +33,10 @@ Tests retrieval of classic administrators with subscription scope function Test-RaClassicAdminsWithScope { # Setup - $subscription = Get-AzSubscription + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' # Test - $classic = Get-AzRoleAssignment -Scope ("/subscriptions/" + $subscription[0].Id) -IncludeClassicAdministrators | Where-Object { $_.Scope.ToLower().Contains("/subscriptions/" + $subscription[0].Id) -and $_.RoleDefinitionName -ieq 'ServiceAdministrator;AccountAdministrator' } - - # Assert - Assert-NotNull $classic - Assert-True { $classic.Length -ge 1 } - - # Test - $classic = Get-AzRoleAssignment -Scope ("/subscriptions/" + $subscription[1].Id) -IncludeClassicAdministrators | Where-Object { $_.Scope.ToLower().Contains("/subscriptions/" + $subscription[1].Id) -and $_.RoleDefinitionName -ieq 'ServiceAdministrator;AccountAdministrator' } + $classic = Get-AzRoleAssignment -Scope $Scope -IncludeClassicAdministrators # Assert Assert-NotNull $classic @@ -76,8 +66,6 @@ Tests verifies negative scenarios for RoleAssignments function Test-RaNegativeScenarios { # Setup - $subscription = $(Get-AzContext).Subscription - # Bad OID returns zero role assignments $badOid = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa' $badObjectResult = "Cannot find principal using the specified options" @@ -324,27 +312,18 @@ Tests verifies creation and deletion of a RoleAssignments for Service principal function Test-RaByServicePrincipal { # Setup - $definitionName = 'Web Plan Contributor' $servicePrincipals = Get-AzADServicePrincipal | Select-Object -Last 1 -Wait - $subscription = $(Get-AzContext).Subscription - $resourceGroups = Get-AzResourceGroup | Select-Object -Last 1 -Wait - $scope = '/subscriptions/'+ $subscription[0].Id Assert-AreEqual 1 $servicePrincipals.Count "No service principals found. Unable to run the test." + $definitionName = 'Web Plan Contributor' + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' + # Test - $newAssignment1 = New-AzRoleAssignmentWithId ` - -ServicePrincipalName $servicePrincipals[0].ServicePrincipalNames[0] ` - -RoleDefinitionName $definitionName ` - -Scope $scope ` - -RoleAssignmentId 0272ecd2-580e-4560-a59e-fd9ed330ee31 + $newAssignment1 = New-AzRoleAssignment -ServicePrincipalName $servicePrincipals[0].ServicePrincipalNames[0] -RoleDefinitionName $definitionName -Scope $scope $definitionName = 'Contributor' # Test - $newAssignment2 = New-AzRoleAssignmentWithId ` - -ApplicationId $servicePrincipals[0].ServicePrincipalNames[0] ` - -RoleDefinitionName $definitionName ` - -Scope $scope ` - -RoleAssignmentId d953d793-bc25-49e9-818b-5ce68f3ff5ed + $newAssignment2 = New-AzRoleAssignment -ApplicationId $servicePrincipals[0].ServicePrincipalNames[0] -RoleDefinitionName $definitionName -Scope $scope $assignments = Get-AzRoleAssignment -ObjectId $newAssignment2.ObjectId Assert-NotNull $assignments @@ -716,23 +695,15 @@ Verifies that creating an ra with an SP displays correct error message #> function Test-RaCreatedBySP { - #Setup - # Conect to azure with SP - # If you need to re-record replace this setup - $passwd = ConvertTo-SecureString 'password' -AsPlainText -Force - $pscredential = New-Object System.Management.Automation.PSCredential('0b0f065d-6d84-4ba0-a6ea-efefa3f54365' , $passwd) - $tenantId = '01fd65cb-2dca-4aa4-8d2a-62b40c9d27d3' - Connect-AzAccount -ServicePrincipal -Credential $pscredential -Tenant $tenantId - + # Prerequisite: Conect to azure with SP # Create role assignment - $testUser = '7aa123be-80d1-4aa8-8813-d6a34a6a52d0' - $data = {New-AzRoleAssignmentWithId ` - -ObjectId $testUser ` - -RoleDefinitionName 'Reader' ` - -Scope '/subscriptions/7ada13d9-fa86-4ea3-bcdc-7545cc0f1bb6' ` - -RoleAssignmentId f0f113bd-7ff9-4eb6-b949-5de18d1b38ca} - - Assert-NotNull $data + # bez's PrincipalId + $testUser ="2f153a9e-5be9-4f43-abd2-04561777c8b0" + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' + + $assignment = New-AzRoleAssignment -ObjectId $testUser -RoleDefinitionName 'Reader' -Scope $Scope + + Assert-NotNull $assignment } <# @@ -742,25 +713,17 @@ Create role assignment with v1 conditions function Test-RaWithV1Conditions{ #Given - $RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7" - $PrincipalId ="7aa123be-80d1-4aa8-8813-d6a34a6a52d0" - $Scope = '/subscriptions/7ada13d9-fa86-4ea3-bcdc-7545cc0f1bb6' + # Built-in role "Storage Blob Data Reader"'s Id + $RoleDefinitionId = "2a2b9908-6ea1-4ae2-8e65-a410df84e7d1" + # bez's PrincipalId + $PrincipalId ="2f153a9e-5be9-4f43-abd2-04561777c8b0" + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' $Description = "This test should not fail" - $Condition = "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'" + $StorageAccount = 'storagecontainer4test' + $Condition = "@Resource[Microsoft.Storage/storageAccounts:name] StringEquals '$StorageAccount'" $ConditionVersion = "1.0" - #When - $data = {New-AzRoleAssignmentWithId ` - -ObjectId $PrincipalId ` - -Scope $Scope ` - -RoleDefinitionId $RoleDefinitionId ` - -Description $Description ` - -Condition $Condition ` - -ConditionVersion $ConditionVersion ` - -RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d1} - - #Then - Assert-Throws $data "Argument -ConditionVersion must be greater or equal than 2.0" + Assert-Throws {New-AzRoleAssignment -ObjectId $PrincipalId -Scope $Scope -RoleDefinitionId $RoleDefinitionId -Description $Description -Condition $Condition -ConditionVersion $ConditionVersion} "Argument -ConditionVersion must be greater or equal than 2.0" } <# @@ -769,22 +732,19 @@ Create role assignment with v2 conditions #> function Test-RaWithV2Conditions{ #Given - $RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7" - $PrincipalId ="7aa123be-80d1-4aa8-8813-d6a34a6a52d0" - $Scope = '/subscriptions/7ada13d9-fa86-4ea3-bcdc-7545cc0f1bb6' + # Built-in role "Storage Blob Data Reader"'s Id + $RoleDefinitionId = "2a2b9908-6ea1-4ae2-8e65-a410df84e7d1" + # bez's PrincipalId + $PrincipalId ="2f153a9e-5be9-4f43-abd2-04561777c8b0" + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' $Description = "This test should not fail" - $Condition = "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:Name] StringEqualsIgnoreCase 'foo_storage_container'" + $StorageAccount = 'storagecontainer4test' + $Condition = "@Resource[Microsoft.Storage/storageAccounts:name] StringEquals '$StorageAccount'" $ConditionVersion = "2.0" #When - $data = New-AzRoleAssignmentWithId ` - -ObjectId $PrincipalId ` - -Scope $Scope ` - -RoleDefinitionId $RoleDefinitionId ` - -Description $Description ` - -Condition $Condition ` - -ConditionVersion $ConditionVersion ` - -RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d2 + $data = New-AzRoleAssignment -ObjectId $PrincipalId -Scope $Scope -RoleDefinitionId $RoleDefinitionId ` + -Description $Description -Condition $Condition -ConditionVersion $ConditionVersion #Then Assert-NotNull $data "The role assignment was not created succesfully" @@ -796,9 +756,7 @@ function Test-RaWithV2Conditions{ Assert-AreEqual $ConditionVersion $data.ConditionVersion "Assertion failed because expected ConditionVersion '$ConditionVersion' does not match actual '$data.ConditionVersion'" #Cleanup - $data = Remove-AzRoleAssignment -InputObject $data - - Assert-Null $data "Role assignment was not deleted properly" + Remove-AzRoleAssignment -InputObject $data } <# @@ -807,34 +765,29 @@ Create role assignment with v2 conditions #> function Test-RaWithV2ConditionsOnly{ #Given - $RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7" - $PrincipalId ="7aa123be-80d1-4aa8-8813-d6a34a6a52d0" - $Scope = '/subscriptions/7ada13d9-fa86-4ea3-bcdc-7545cc0f1bb6' + # Built-in role "Storage Blob Data Reader"'s Id + $RoleDefinitionId = "2a2b9908-6ea1-4ae2-8e65-a410df84e7d1" + # bez's PrincipalId + $PrincipalId ="2f153a9e-5be9-4f43-abd2-04561777c8b0" + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' $Description = "This test should not fail" - $Condition = "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:Name] StringEqualsIgnoreCase 'foo_storage_container'" + $StorageAccount = 'storagecontainer4test' + $Condition = "@Resource[Microsoft.Storage/storageAccounts:name] StringEquals '$StorageAccount'" #When - $data = New-AzRoleAssignmentWithId ` - -ObjectId $PrincipalId ` - -Scope $Scope ` - -RoleDefinitionId $RoleDefinitionId ` - -Description $Description ` - -Condition $Condition ` - -RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d2 + $assignment = New-AzRoleAssignment -ObjectId $PrincipalId -Scope $Scope -RoleDefinitionId $RoleDefinitionId -Description $Description -Condition $Condition #Then - Assert-NotNull $data "The role assignment was not created succesfully" - Assert-AreEqual $RoleDefinitionId $data.RoleDefinitionId "Assertion failed because expected RoleDefinitionId '$RoleDefinitionId' does not match actual '$data.RoleDefinitionId'" - Assert-AreEqual $PrincipalId $data.ObjectId "Assertion failed because expected PrincipalId '$PrincipalId' does not match actual '$data.ObjectId'" - Assert-AreEqual $Scope $data.Scope "Assertion failed because expected Scope '$Scope' does not match actual '$data.Scope'" - Assert-AreEqual $Description $data.Description "Assertion failed because expected Description '$Description' does not match actual '$data.Description'" - Assert-AreEqual $Condition $data.Condition "Assertion failed because expected Condition '$Condition' does not match actual '$data.Condition'" - Assert-AreEqual "2.0" $data.ConditionVersion "Assertion failed because expected ConditionVersion '$ConditionVersion' does not match actual '$data.ConditionVersion'" + Assert-NotNull $assignment "The role assignment was not created succesfully" + Assert-AreEqual $RoleDefinitionId $assignment.RoleDefinitionId "Assertion failed because expected RoleDefinitionId '$RoleDefinitionId' does not match actual '$data.RoleDefinitionId'" + Assert-AreEqual $PrincipalId $assignment.ObjectId "Assertion failed because expected PrincipalId '$PrincipalId' does not match actual '$data.ObjectId'" + Assert-AreEqual $Scope $assignment.Scope "Assertion failed because expected Scope '$Scope' does not match actual '$data.Scope'" + Assert-AreEqual $Description $assignment.Description "Assertion failed because expected Description '$Description' does not match actual '$data.Description'" + Assert-AreEqual $Condition $assignment.Condition "Assertion failed because expected Condition '$Condition' does not match actual '$data.Condition'" + Assert-AreEqual "2.0" $assignment.ConditionVersion "Assertion failed because expected ConditionVersion '$ConditionVersion' does not match actual '$data.ConditionVersion'" #Cleanup - $data = Remove-AzRoleAssignment -InputObject $data - - Assert-Null $data "Role assignment was not deleted properly" + Remove-AzRoleAssignment -InputObject $assignment } <# @@ -843,23 +796,15 @@ Create role assignment with v2 conditions #> function Test-RaWithV2ConditionVersionOnly{ #Given - $RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7" - $PrincipalId ="7aa123be-80d1-4aa8-8813-d6a34a6a52d0" - $Scope = '/subscriptions/7ada13d9-fa86-4ea3-bcdc-7545cc0f1bb6' + # Built-in role "Storage Blob Data Reader"'s Id + $RoleDefinitionId = "2a2b9908-6ea1-4ae2-8e65-a410df84e7d1" + # bez's PrincipalId + $PrincipalId ="2f153a9e-5be9-4f43-abd2-04561777c8b0" + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' $Description = "This test should not fail" $ConditionVersion = "2.0" - #When - $data = {New-AzRoleAssignmentWithId ` - -ObjectId $PrincipalId ` - -Scope $Scope ` - -RoleDefinitionId $RoleDefinitionId ` - -Description $Description ` - -ConditionVersion $ConditionVersion ` - -RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d2} - - #Then - Assert-Throws $data "If -ConditionVersion is set -Condition can not be empty." + Assert-Throws {New-AzRoleAssignment -ObjectId $PrincipalId -Scope $Scope -RoleDefinitionId $RoleDefinitionId -Description $Description -ConditionVersion $ConditionVersion} "If -ConditionVersion is set -Condition can not be empty." } <# @@ -869,59 +814,47 @@ update role assignment with v2 conditions function Test-UpdateRa{ # Given - $RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7" - $PrincipalId ="a9bd2ca0-f2c6-41d5-81e7-4da601e7365a" - $Scope = '/subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f' + # Built-in role "Storage Blob Data Reader"'s Id + $RoleDefinitionId = "2a2b9908-6ea1-4ae2-8e65-a410df84e7d1" + # bez's PrincipalId + $PrincipalId ="2f153a9e-5be9-4f43-abd2-04561777c8b0" + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' $Description1 = "This test should not fail" - $Condition1 = "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:Name] StringEqualsIgnoreCase 'foo_storage_container'" + $StorageAccount = 'storagecontainer4test' + $Condition1 = "@Resource[Microsoft.Storage/storageAccounts:name] StringEquals '$StorageAccount'" $ConditionVersion = "2.0" - $Description2 = "This test should have completed" - $Condition2 = "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers/blobs:Path] StringEqualsIgnoreCase 'foo_storage_container'" # When - $dataOld = New-AzRoleAssignmentWithId ` - -ObjectId $PrincipalId ` - -Scope $Scope ` - -RoleDefinitionId $RoleDefinitionId ` - -Description $Description1 ` - -Condition $Condition1 ` - -ConditionVersion $ConditionVersion ` - -RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d2 + $assignment = New-AzRoleAssignment -ObjectId $PrincipalId -Scope $Scope -RoleDefinitionId $RoleDefinitionId -Description $Description1 ` + -Condition $Condition1 -ConditionVersion $ConditionVersion - $dataNew = New-AzRoleAssignmentWithId ` - -ObjectId $PrincipalId ` - -Scope $Scope ` - -RoleDefinitionId $RoleDefinitionId ` - -Description $Description1 ` - -Condition $Condition1 ` - -ConditionVersion $ConditionVersion ` - -RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d2 - - $dataNew.Description = $Description2 - $dataNew.Condition = $Condition2 - - $dataNew = Set-AzRoleAssignment ` - -InputObject $dataNew ` - -PassThru + $Description2 = "This test should have completed" + $Condition2 = "true" + + $assignment.Description = $Description2 + $assignment.Condition = $Condition2 + + $updatedAssignment = Set-AzRoleAssignment -InputObject $assignment -PassThru # Then # Assert intended target changed - Assert-AreNotEqual $dataOld.Description $dataNew.Description "Test failed: description didn't change after update call" - Assert-AreNotEqual $dataOld.Condition $dataNew.Condition "Test failed: condition didn't change after update call" + Assert-AreNotEqual $Description1 $updatedAssignment.Description "Test failed: description didn't change after update call" + Assert-AreNotEqual $Condition1 $updatedAssignment.Condition "Test failed: condition didn't change after update call" + Assert-AreEqual $Description2 $updatedAssignment.Description "Test failed: description didn't change as demand" + Assert-AreEqual $Condition2 $updatedAssignment.Condition "Test failed: condition didn't change as demand" # Assert there where no unintended changes - Assert-AreEqual $dataOld.ObjectId $dataNew.ObjectId "Test failed: ObjectId shouldn't have changed after update call" - Assert-AreEqual $dataOld.Scope $dataNew.Scope "Test failed: Scope shouldn't have changed after update call" - Assert-AreEqual $dataOld.RoleDefinitionId $dataNew.RoleDefinitionId "Test failed: RoleDefinitionId shouldn't have changed after update call" - # Consider deleting bellow assert for certain tests as we might overwrite vondition version behind the seams - Assert-AreEqual $dataOld.ConditionVersion $dataNew.ConditionVersion "Test failed: ConditionVersion shouldn't have changed after update call" - Assert-AreEqual $dataOld.RoleAssignmentId $dataNew.RoleAssignmentId "Test failed: RoleAssignmentId shouldn't have changed after update call" + Assert-AreEqual $PrincipalId $updatedAssignment.ObjectId "Test failed: ObjectId shouldn't have changed after update call" + Assert-AreEqual $Scope $updatedAssignment.Scope "Test failed: Scope shouldn't have changed after update call" + Assert-AreEqual $RoleDefinitionId $updatedAssignment.RoleDefinitionId "Test failed: RoleDefinitionId shouldn't have changed after update call" + + # Consider deleting bellow assert for certain tests as we might overwrite condition version behind the seams + Assert-AreEqual $ConditionVersion $updatedAssignment.ConditionVersion "Test failed: ConditionVersion shouldn't have changed after update call" + Assert-AreEqual $assignment.RoleAssignmentId $updatedAssignment.RoleAssignmentId "Test failed: RoleAssignmentId shouldn't have changed after update call" #Cleanup - $data = Remove-AzRoleAssignment -InputObject $dataNew - - Assert-Null $data "Role assignment was not deleted properly" + Remove-AzRoleAssignment -InputObject $updatedAssignment } <# @@ -932,15 +865,11 @@ function Test-CreateRAForGroup { #Given $RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7" - $PrincipalId ="7aa123be-80d1-4aa8-8813-d6a34a6a52d0" - $Scope = '/subscriptions/7ada13d9-fa86-4ea3-bcdc-7545cc0f1bb6' + $PrincipalId ="ffa6ed11-e137-4081-ad6e-77a25ddd685a" + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' #When - $data = New-AzRoleAssignmentWithId ` - -ObjectId $PrincipalId ` - -Scope $Scope ` - -RoleDefinitionId $RoleDefinitionId ` - -RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d1 + $data = New-AzRoleAssignment -ObjectId $PrincipalId -Scope $Scope -RoleDefinitionId $RoleDefinitionId Assert-True {$data.ObjectType -eq "Group"} } @@ -953,15 +882,11 @@ function Test-CreateRAForGuest { #Given $RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7" - $PrincipalId ="7aa123be-80d1-4aa8-8813-d6a34a6a52d0" - $Scope = '/subscriptions/7ada13d9-fa86-4ea3-bcdc-7545cc0f1bb6' + $PrincipalId ="2f153a9e-5be9-4f43-abd2-04561777c8b0" + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' #When - $data = New-AzRoleAssignmentWithId ` - -ObjectId $PrincipalId ` - -Scope $Scope ` - -RoleDefinitionId $RoleDefinitionId ` - -RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d2 + $data = New-AzRoleAssignment -ObjectId $PrincipalId -Scope $Scope -RoleDefinitionId $RoleDefinitionId Assert-True {$data.ObjectType -eq "User"} } @@ -974,15 +899,11 @@ function Test-CreateRAForMember { #Given $RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7" - $PrincipalId ="7aa123be-80d1-4aa8-8813-d6a34a6a52d0" - $Scope = '/subscriptions/7ada13d9-fa86-4ea3-bcdc-7545cc0f1bb6' + $PrincipalId ="2f153a9e-5be9-4f43-abd2-04561777c8b0" + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' #When - $data = New-AzRoleAssignmentWithId ` - -ObjectId $PrincipalId ` - -Scope $Scope ` - -RoleDefinitionId $RoleDefinitionId ` - -RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d3 + $data = New-AzRoleAssignment -ObjectId $PrincipalId -Scope $Scope -RoleDefinitionId $RoleDefinitionId Assert-True {$data.ObjectType -eq "User"} } @@ -994,16 +915,13 @@ Verifies that role assignment maps to a ServicePrincipal function Test-CreateRAForServicePrincipal { #Given - $RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7" - $PrincipalId ="7aa123be-80d1-4aa8-8813-d6a34a6a52d0" - $Scope = '/subscriptions/7ada13d9-fa86-4ea3-bcdc-7545cc0f1bb6' + # Built-in role "Storage Blob Data Reader"'s Id + $RoleDefinitionId = "2a2b9908-6ea1-4ae2-8e65-a410df84e7d1" + $PrincipalId ="7ed39736-e04f-4384-964f-b2b525de3280" + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' #When - $data = New-AzRoleAssignmentWithId ` - -ObjectId $PrincipalId ` - -Scope $Scope ` - -RoleDefinitionId $RoleDefinitionId ` - -RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d4 + $data = New-AzRoleAssignment -ObjectId $PrincipalId -Scope $Scope -RoleDefinitionId $RoleDefinitionId Assert-True {$data.ObjectType -eq "ServicePrincipal"} } @@ -1016,17 +934,14 @@ function Test-CreateRAWithObjectType { #Given $RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7" - $PrincipalId ="7aa123be-80d1-4aa8-8813-d6a34a6a52d0" + # bez's PrincipalId + $PrincipalId ="2f153a9e-5be9-4f43-abd2-04561777c8b0" $subscription = (Get-AzContext).Subscription.Id $Scope = "/subscriptions/$subscription" $ObjectType = "User" #When - $data = New-AzRoleAssignmentWithId ` - -ObjectId $PrincipalId ` - -ObjectType $ObjectType ` - -Scope $Scope ` - -RoleDefinitionId $RoleDefinitionId ` + $data = New-AzRoleAssignment -ObjectId $PrincipalId -ObjectType $ObjectType -Scope $Scope -RoleDefinitionId $RoleDefinitionId ` -RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d9 Assert-True {$data.ObjectType -eq "User"} @@ -1041,15 +956,11 @@ function Test-CreateRAWhenIdNotExist #Given $RoleDefinitionId = "acdd72a7-3385-48ef-bd42-f606fba81ae7" $PrincipalId ="6d764d35-6b3b-49ea-83f8-5c223b56eac5" - $Scope = '/subscriptions/70cff36b-c4f8-46ea-9655-9cfd44664763' - $ExpectedError = "Exception calling `"ExecuteCmdlet`" with `"0`" argument(s): `"Operation returned an invalid status code 'NotFound'`"" + $Scope = '/subscriptions/0b1f6471-1bf0-4dda-aec3-cb9272f09590' + $ExpectedError = "Principal 6d764d356b3b49ea83f85c223b56eac5 does not exist in the directory 54826b22-38d6-4fb2-bad9-b7b93a3e9c5a" #When - $function = {New-AzRoleAssignmentWithId ` - -ObjectId $PrincipalId ` - -Scope $Scope ` - -RoleDefinitionId $RoleDefinitionId ` - -RoleAssignmentId 734de5f5-c680-41c0-8beb-67b98c3539d5} + $function = { New-AzRoleAssignment -ObjectId $PrincipalId -Scope $Scope -RoleDefinitionId $RoleDefinitionId } Assert-Throws $function $ExpectedError } \ No newline at end of file diff --git a/src/Resources/Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.DeploymentTests/TestTestDeploymentFromBicepFile.json b/src/Resources/Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.DeploymentTests/TestTestDeploymentFromBicepFile.json index 2b38b83849d3..f9c8ed45a1c0 100644 --- a/src/Resources/Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.DeploymentTests/TestTestDeploymentFromBicepFile.json +++ b/src/Resources/Resources.Test/SessionRecords/Microsoft.Azure.Commands.Resources.Test.ScenarioTests.DeploymentTests/TestTestDeploymentFromBicepFile.json @@ -1,22 +1,22 @@ { "Entries": [ { - "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/ps6032?api-version=2020-10-01", - "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL3Jlc291cmNlZ3JvdXBzL3BzNjAzMj9hcGktdmVyc2lvbj0yMDIwLTEwLTAx", + "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/ps3986?api-version=2021-04-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL3Jlc291cmNlZ3JvdXBzL3BzMzk4Nj9hcGktdmVyc2lvbj0yMDIxLTA0LTAx", "RequestMethod": "HEAD", "RequestBody": "", "RequestHeaders": { "x-ms-client-request-id": [ - "f4ab663d-48ae-4a17-bf6e-9620cfc9bb58" + "a19bfd78-9790-4325-b6b2-6a7f9e800124" ], "Accept-Language": [ "en-US" ], "User-Agent": [ - "FxVersion/4.6.29518.01", + "FxVersion/4.6.30411.01", "OSName/Windows", - "OSVersion/Microsoft.Windows.10.0.19042.", - "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.11.0.0" + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.13.2.0" ] }, "ResponseHeaders": { @@ -30,16 +30,16 @@ "gateway" ], "x-ms-ratelimit-remaining-subscription-reads": [ - "11997" + "11999" ], "x-ms-request-id": [ - "58ca855a-278f-4a0e-aa5f-87693562fa25" + "b3d75e42-a150-4d35-ae91-0a6bfc99e841" ], "x-ms-correlation-request-id": [ - "58ca855a-278f-4a0e-aa5f-87693562fa25" + "b3d75e42-a150-4d35-ae91-0a6bfc99e841" ], "x-ms-routing-request-id": [ - "SOUTHEASTASIA:20210202T094528Z:58ca855a-278f-4a0e-aa5f-87693562fa25" + "SOUTHEASTASIA:20211111T084413Z:b3d75e42-a150-4d35-ae91-0a6bfc99e841" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -48,7 +48,7 @@ "nosniff" ], "Date": [ - "Tue, 02 Feb 2021 09:45:28 GMT" + "Thu, 11 Nov 2021 08:44:12 GMT" ], "Content-Length": [ "98" @@ -67,22 +67,22 @@ "StatusCode": 404 }, { - "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/ps6032?api-version=2020-10-01", - "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL3Jlc291cmNlZ3JvdXBzL3BzNjAzMj9hcGktdmVyc2lvbj0yMDIwLTEwLTAx", + "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/ps3986?api-version=2021-04-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL3Jlc291cmNlZ3JvdXBzL3BzMzk4Nj9hcGktdmVyc2lvbj0yMDIxLTA0LTAx", "RequestMethod": "HEAD", "RequestBody": "", "RequestHeaders": { "x-ms-client-request-id": [ - "16c538d6-4403-4cdc-a184-f643b81fe4db" + "b23d0a97-be71-4f27-91a4-0dde4e4c0b90" ], "Accept-Language": [ "en-US" ], "User-Agent": [ - "FxVersion/4.6.29518.01", + "FxVersion/4.6.30411.01", "OSName/Windows", - "OSVersion/Microsoft.Windows.10.0.19042.", - "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.11.0.0" + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.13.2.0" ] }, "ResponseHeaders": { @@ -93,16 +93,16 @@ "no-cache" ], "x-ms-ratelimit-remaining-subscription-reads": [ - "11993" + "11999" ], "x-ms-request-id": [ - "0b605887-cfaf-4160-9694-9543f3a557fe" + "04d4e2b1-1bf7-4f28-a824-ac25b585ef3d" ], "x-ms-correlation-request-id": [ - "0b605887-cfaf-4160-9694-9543f3a557fe" + "04d4e2b1-1bf7-4f28-a824-ac25b585ef3d" ], "x-ms-routing-request-id": [ - "SOUTHEASTASIA:20210202T094535Z:0b605887-cfaf-4160-9694-9543f3a557fe" + "SOUTHEASTASIA:20211111T084422Z:04d4e2b1-1bf7-4f28-a824-ac25b585ef3d" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -111,7 +111,7 @@ "nosniff" ], "Date": [ - "Tue, 02 Feb 2021 09:45:35 GMT" + "Thu, 11 Nov 2021 08:44:22 GMT" ], "Content-Length": [ "0" @@ -127,22 +127,22 @@ "StatusCode": 204 }, { - "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/ps6032?api-version=2020-10-01", - "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL3Jlc291cmNlZ3JvdXBzL3BzNjAzMj9hcGktdmVyc2lvbj0yMDIwLTEwLTAx", + "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/ps3986?api-version=2021-04-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL3Jlc291cmNlZ3JvdXBzL3BzMzk4Nj9hcGktdmVyc2lvbj0yMDIxLTA0LTAx", "RequestMethod": "PUT", "RequestBody": "{\r\n \"location\": \"West US 2\"\r\n}", "RequestHeaders": { "x-ms-client-request-id": [ - "9ea64a64-6ee5-4565-b0a0-088bcb4db1b4" + "a19bfd78-9790-4325-b6b2-6a7f9e800124" ], "Accept-Language": [ "en-US" ], "User-Agent": [ - "FxVersion/4.6.29518.01", + "FxVersion/4.6.30411.01", "OSName/Windows", - "OSVersion/Microsoft.Windows.10.0.19042.", - "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.11.0.0" + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.13.2.0" ], "Content-Type": [ "application/json; charset=utf-8" @@ -159,16 +159,16 @@ "no-cache" ], "x-ms-ratelimit-remaining-subscription-writes": [ - "1197" + "1199" ], "x-ms-request-id": [ - "91b7e299-bd70-4718-b30d-4eee592d3184" + "bd956995-a6d9-41a9-b95e-057c9585593d" ], "x-ms-correlation-request-id": [ - "91b7e299-bd70-4718-b30d-4eee592d3184" + "bd956995-a6d9-41a9-b95e-057c9585593d" ], "x-ms-routing-request-id": [ - "SOUTHEASTASIA:20210202T094530Z:91b7e299-bd70-4718-b30d-4eee592d3184" + "SOUTHEASTASIA:20211111T084415Z:bd956995-a6d9-41a9-b95e-057c9585593d" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -177,7 +177,7 @@ "nosniff" ], "Date": [ - "Tue, 02 Feb 2021 09:45:30 GMT" + "Thu, 11 Nov 2021 08:44:14 GMT" ], "Content-Length": [ "210" @@ -192,32 +192,32 @@ "0" ] }, - "ResponseBody": "{\r\n \"id\": \"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/ps6032\",\r\n \"name\": \"ps6032\",\r\n \"type\": \"Microsoft.Resources/resourceGroups\",\r\n \"location\": \"westus2\",\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}", + "ResponseBody": "{\r\n \"id\": \"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/ps3986\",\r\n \"name\": \"ps3986\",\r\n \"type\": \"Microsoft.Resources/resourceGroups\",\r\n \"location\": \"westus2\",\r\n \"properties\": {\r\n \"provisioningState\": \"Succeeded\"\r\n }\r\n}", "StatusCode": 201 }, { - "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/ps6032/providers/Microsoft.Resources/deployments/69d6ffd5-2e5d-4815-b511-8c4d9d28fc50/validate?api-version=2020-10-01", - "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL3Jlc291cmNlZ3JvdXBzL3BzNjAzMi9wcm92aWRlcnMvTWljcm9zb2Z0LlJlc291cmNlcy9kZXBsb3ltZW50cy82OWQ2ZmZkNS0yZTVkLTQ4MTUtYjUxMS04YzRkOWQyOGZjNTAvdmFsaWRhdGU/YXBpLXZlcnNpb249MjAyMC0xMC0wMQ==", + "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/ps3986/providers/Microsoft.Resources/deployments/c4f0b5a8-8ff3-4a21-afd3-5862696db97c/validate?api-version=2021-04-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL3Jlc291cmNlZ3JvdXBzL3BzMzk4Ni9wcm92aWRlcnMvTWljcm9zb2Z0LlJlc291cmNlcy9kZXBsb3ltZW50cy9jNGYwYjVhOC04ZmYzLTRhMjEtYWZkMy01ODYyNjk2ZGI5N2MvdmFsaWRhdGU/YXBpLXZlcnNpb249MjAyMS0wNC0wMQ==", "RequestMethod": "POST", - "RequestBody": "{\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"parameters\": {\r\n \"location\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"westus\"\r\n },\r\n \"name\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"bezstorage007\"\r\n }\r\n },\r\n \"functions\": [],\r\n \"variables\": {\r\n \"storageSku\": \"Standard_LRS\"\r\n },\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Storage/storageAccounts\",\r\n \"apiVersion\": \"2019-06-01\",\r\n \"name\": \"[parameters('name')]\",\r\n \"location\": \"[parameters('location')]\",\r\n \"kind\": \"Storage\",\r\n \"sku\": {\r\n \"name\": \"[variables('storageSku')]\"\r\n }\r\n }\r\n ],\r\n \"outputs\": {\r\n \"storageId\": {\r\n \"type\": \"string\",\r\n \"value\": \"[resourceId('Microsoft.Storage/storageAccounts', parameters('name'))]\"\r\n }\r\n }\r\n },\r\n \"parameters\": {},\r\n \"mode\": \"Incremental\"\r\n }\r\n}", + "RequestBody": "{\r\n \"properties\": {\r\n \"template\": {\r\n \"$schema\": \"https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#\",\r\n \"contentVersion\": \"1.0.0.0\",\r\n \"metadata\": {\r\n \"_generator\": {\r\n \"name\": \"bicep\",\r\n \"version\": \"0.4.1008.15138\",\r\n \"templateHash\": \"17163715440761429628\"\r\n }\r\n },\r\n \"parameters\": {\r\n \"location\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"westus\"\r\n },\r\n \"name\": {\r\n \"type\": \"string\",\r\n \"defaultValue\": \"bezstorage007\"\r\n }\r\n },\r\n \"functions\": [],\r\n \"variables\": {\r\n \"storageSku\": \"Standard_LRS\"\r\n },\r\n \"resources\": [\r\n {\r\n \"type\": \"Microsoft.Storage/storageAccounts\",\r\n \"apiVersion\": \"2019-06-01\",\r\n \"name\": \"[parameters('name')]\",\r\n \"location\": \"[parameters('location')]\",\r\n \"kind\": \"Storage\",\r\n \"sku\": {\r\n \"name\": \"[variables('storageSku')]\"\r\n }\r\n }\r\n ],\r\n \"outputs\": {\r\n \"storageId\": {\r\n \"type\": \"string\",\r\n \"value\": \"[resourceId('Microsoft.Storage/storageAccounts', parameters('name'))]\"\r\n }\r\n }\r\n },\r\n \"parameters\": {},\r\n \"mode\": \"Incremental\"\r\n }\r\n}", "RequestHeaders": { "x-ms-client-request-id": [ - "629b0228-f209-4824-89ab-f714eb48d721" + "ab107747-e48d-4d39-9b5c-8cbed5dcd070" ], "Accept-Language": [ "en-US" ], "User-Agent": [ - "FxVersion/4.6.29518.01", + "FxVersion/4.6.30411.01", "OSName/Windows", - "OSVersion/Microsoft.Windows.10.0.19042.", - "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.11.0.0" + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.13.2.0" ], "Content-Type": [ "application/json; charset=utf-8" ], "Content-Length": [ - "1111" + "1296" ] }, "ResponseHeaders": { @@ -228,16 +228,16 @@ "no-cache" ], "x-ms-ratelimit-remaining-subscription-writes": [ - "1198" + "1199" ], "x-ms-request-id": [ - "c43ae395-a81f-4f47-9322-336b5ebcf00f" + "86b43949-f75d-47a3-a26c-f8545c5ec12a" ], "x-ms-correlation-request-id": [ - "c43ae395-a81f-4f47-9322-336b5ebcf00f" + "86b43949-f75d-47a3-a26c-f8545c5ec12a" ], "x-ms-routing-request-id": [ - "SOUTHEASTASIA:20210202T094534Z:c43ae395-a81f-4f47-9322-336b5ebcf00f" + "SOUTHEASTASIA:20211111T084422Z:86b43949-f75d-47a3-a26c-f8545c5ec12a" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -246,7 +246,7 @@ "nosniff" ], "Date": [ - "Tue, 02 Feb 2021 09:45:34 GMT" + "Thu, 11 Nov 2021 08:44:21 GMT" ], "Content-Length": [ "886" @@ -261,26 +261,26 @@ "0" ] }, - "ResponseBody": "{\r\n \"id\": \"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/ps6032/providers/Microsoft.Resources/deployments/69d6ffd5-2e5d-4815-b511-8c4d9d28fc50\",\r\n \"name\": \"69d6ffd5-2e5d-4815-b511-8c4d9d28fc50\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"properties\": {\r\n \"templateHash\": \"15467936349540559989\",\r\n \"parameters\": {\r\n \"location\": {\r\n \"type\": \"String\",\r\n \"value\": \"westus\"\r\n },\r\n \"name\": {\r\n \"type\": \"String\",\r\n \"value\": \"bezstorage007\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2021-02-02T09:45:33.8302784Z\",\r\n \"duration\": \"PT0S\",\r\n \"correlationId\": \"c43ae395-a81f-4f47-9322-336b5ebcf00f\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Storage\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"storageAccounts\",\r\n \"locations\": [\r\n \"westus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [],\r\n \"validatedResources\": [\r\n {\r\n \"id\": \"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/ps6032/providers/Microsoft.Storage/storageAccounts/bezstorage007\"\r\n }\r\n ]\r\n }\r\n}", + "ResponseBody": "{\r\n \"id\": \"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/ps3986/providers/Microsoft.Resources/deployments/c4f0b5a8-8ff3-4a21-afd3-5862696db97c\",\r\n \"name\": \"c4f0b5a8-8ff3-4a21-afd3-5862696db97c\",\r\n \"type\": \"Microsoft.Resources/deployments\",\r\n \"properties\": {\r\n \"templateHash\": \"17163715440761429628\",\r\n \"parameters\": {\r\n \"location\": {\r\n \"type\": \"String\",\r\n \"value\": \"westus\"\r\n },\r\n \"name\": {\r\n \"type\": \"String\",\r\n \"value\": \"bezstorage007\"\r\n }\r\n },\r\n \"mode\": \"Incremental\",\r\n \"provisioningState\": \"Succeeded\",\r\n \"timestamp\": \"2021-11-11T08:44:20.9455383Z\",\r\n \"duration\": \"PT0S\",\r\n \"correlationId\": \"86b43949-f75d-47a3-a26c-f8545c5ec12a\",\r\n \"providers\": [\r\n {\r\n \"namespace\": \"Microsoft.Storage\",\r\n \"resourceTypes\": [\r\n {\r\n \"resourceType\": \"storageAccounts\",\r\n \"locations\": [\r\n \"westus\"\r\n ]\r\n }\r\n ]\r\n }\r\n ],\r\n \"dependencies\": [],\r\n \"validatedResources\": [\r\n {\r\n \"id\": \"/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/ps3986/providers/Microsoft.Storage/storageAccounts/bezstorage007\"\r\n }\r\n ]\r\n }\r\n}", "StatusCode": 200 }, { - "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/ps6032?api-version=2020-10-01", - "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL3Jlc291cmNlZ3JvdXBzL3BzNjAzMj9hcGktdmVyc2lvbj0yMDIwLTEwLTAx", + "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourcegroups/ps3986?api-version=2021-04-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL3Jlc291cmNlZ3JvdXBzL3BzMzk4Nj9hcGktdmVyc2lvbj0yMDIxLTA0LTAx", "RequestMethod": "DELETE", "RequestBody": "", "RequestHeaders": { "x-ms-client-request-id": [ - "b04fd680-e4ea-4190-a8e6-770077aa65ef" + "b23d0a97-be71-4f27-91a4-0dde4e4c0b90" ], "Accept-Language": [ "en-US" ], "User-Agent": [ - "FxVersion/4.6.29518.01", + "FxVersion/4.6.30411.01", "OSName/Windows", - "OSVersion/Microsoft.Windows.10.0.19042.", - "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.11.0.0" + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.13.2.0" ] }, "ResponseHeaders": { @@ -291,22 +291,142 @@ "no-cache" ], "Location": [ - "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzYwMzItV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-10-01" + "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzM5ODYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2021-04-01" ], "Retry-After": [ "0" ], "x-ms-ratelimit-remaining-subscription-deletes": [ - "14998" + "14999" + ], + "x-ms-request-id": [ + "22dffafc-93f7-4e6b-8ba6-c750c5e0aaf0" + ], + "x-ms-correlation-request-id": [ + "22dffafc-93f7-4e6b-8ba6-c750c5e0aaf0" + ], + "x-ms-routing-request-id": [ + "SOUTHEASTASIA:20211111T084426Z:22dffafc-93f7-4e6b-8ba6-c750c5e0aaf0" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Thu, 11 Nov 2021 08:44:26 GMT" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "0" + ] + }, + "ResponseBody": "", + "StatusCode": 202 + }, + { + "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzM5ODYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2021-04-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVXpNNU9EWXRWMFZUVkZWVE1pSXNJbXB2WWt4dlkyRjBhVzl1SWpvaWQyVnpkSFZ6TWlKOT9hcGktdmVyc2lvbj0yMDIxLTA0LTAx", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "b23d0a97-be71-4f27-91a4-0dde4e4c0b90" + ], + "User-Agent": [ + "FxVersion/4.6.30411.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.13.2.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Location": [ + "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzM5ODYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2021-04-01" + ], + "Retry-After": [ + "0" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11998" + ], + "x-ms-request-id": [ + "df9d3c3f-b096-4a1c-8161-3a890e609778" + ], + "x-ms-correlation-request-id": [ + "df9d3c3f-b096-4a1c-8161-3a890e609778" + ], + "x-ms-routing-request-id": [ + "SOUTHEASTASIA:20211111T084442Z:df9d3c3f-b096-4a1c-8161-3a890e609778" + ], + "Strict-Transport-Security": [ + "max-age=31536000; includeSubDomains" + ], + "X-Content-Type-Options": [ + "nosniff" + ], + "Date": [ + "Thu, 11 Nov 2021 08:44:41 GMT" + ], + "Expires": [ + "-1" + ], + "Content-Length": [ + "0" + ] + }, + "ResponseBody": "", + "StatusCode": 202 + }, + { + "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzM5ODYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2021-04-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVXpNNU9EWXRWMFZUVkZWVE1pSXNJbXB2WWt4dlkyRjBhVzl1SWpvaWQyVnpkSFZ6TWlKOT9hcGktdmVyc2lvbj0yMDIxLTA0LTAx", + "RequestMethod": "GET", + "RequestBody": "", + "RequestHeaders": { + "x-ms-client-request-id": [ + "b23d0a97-be71-4f27-91a4-0dde4e4c0b90" + ], + "User-Agent": [ + "FxVersion/4.6.30411.01", + "OSName/Windows", + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.13.2.0" + ] + }, + "ResponseHeaders": { + "Cache-Control": [ + "no-cache" + ], + "Pragma": [ + "no-cache" + ], + "Location": [ + "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzM5ODYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2021-04-01" + ], + "Retry-After": [ + "0" + ], + "x-ms-ratelimit-remaining-subscription-reads": [ + "11997" ], "x-ms-request-id": [ - "7f7c8c94-492e-4270-8536-4529b7258563" + "08df259e-ccfa-4da1-9192-fb6b256a1fd1" ], "x-ms-correlation-request-id": [ - "7f7c8c94-492e-4270-8536-4529b7258563" + "08df259e-ccfa-4da1-9192-fb6b256a1fd1" ], "x-ms-routing-request-id": [ - "SOUTHEASTASIA:20210202T094538Z:7f7c8c94-492e-4270-8536-4529b7258563" + "SOUTHEASTASIA:20211111T084457Z:08df259e-ccfa-4da1-9192-fb6b256a1fd1" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -315,7 +435,7 @@ "nosniff" ], "Date": [ - "Tue, 02 Feb 2021 09:45:38 GMT" + "Thu, 11 Nov 2021 08:44:56 GMT" ], "Expires": [ "-1" @@ -328,16 +448,19 @@ "StatusCode": 202 }, { - "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzYwMzItV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-10-01", - "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVXpZd016SXRWMFZUVkZWVE1pSXNJbXB2WWt4dlkyRjBhVzl1SWpvaWQyVnpkSFZ6TWlKOT9hcGktdmVyc2lvbj0yMDIwLTEwLTAx", + "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzM5ODYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2021-04-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVXpNNU9EWXRWMFZUVkZWVE1pSXNJbXB2WWt4dlkyRjBhVzl1SWpvaWQyVnpkSFZ6TWlKOT9hcGktdmVyc2lvbj0yMDIxLTA0LTAx", "RequestMethod": "GET", "RequestBody": "", "RequestHeaders": { + "x-ms-client-request-id": [ + "b23d0a97-be71-4f27-91a4-0dde4e4c0b90" + ], "User-Agent": [ - "FxVersion/4.6.29518.01", + "FxVersion/4.6.30411.01", "OSName/Windows", - "OSVersion/Microsoft.Windows.10.0.19042.", - "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.11.0.0" + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.13.2.0" ] }, "ResponseHeaders": { @@ -348,22 +471,22 @@ "no-cache" ], "Location": [ - "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzYwMzItV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-10-01" + "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzM5ODYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2021-04-01" ], "Retry-After": [ "0" ], "x-ms-ratelimit-remaining-subscription-reads": [ - "11992" + "11996" ], "x-ms-request-id": [ - "a13693e9-c387-4bd5-8eb6-1a8a7fc55e89" + "ca4bb115-f68b-4c6e-a023-72b85249d2ea" ], "x-ms-correlation-request-id": [ - "a13693e9-c387-4bd5-8eb6-1a8a7fc55e89" + "ca4bb115-f68b-4c6e-a023-72b85249d2ea" ], "x-ms-routing-request-id": [ - "SOUTHEASTASIA:20210202T094554Z:a13693e9-c387-4bd5-8eb6-1a8a7fc55e89" + "SOUTHEASTASIA:20211111T084513Z:ca4bb115-f68b-4c6e-a023-72b85249d2ea" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -372,7 +495,7 @@ "nosniff" ], "Date": [ - "Tue, 02 Feb 2021 09:45:53 GMT" + "Thu, 11 Nov 2021 08:45:12 GMT" ], "Expires": [ "-1" @@ -385,16 +508,19 @@ "StatusCode": 202 }, { - "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzYwMzItV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-10-01", - "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVXpZd016SXRWMFZUVkZWVE1pSXNJbXB2WWt4dlkyRjBhVzl1SWpvaWQyVnpkSFZ6TWlKOT9hcGktdmVyc2lvbj0yMDIwLTEwLTAx", + "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzM5ODYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2021-04-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVXpNNU9EWXRWMFZUVkZWVE1pSXNJbXB2WWt4dlkyRjBhVzl1SWpvaWQyVnpkSFZ6TWlKOT9hcGktdmVyc2lvbj0yMDIxLTA0LTAx", "RequestMethod": "GET", "RequestBody": "", "RequestHeaders": { + "x-ms-client-request-id": [ + "b23d0a97-be71-4f27-91a4-0dde4e4c0b90" + ], "User-Agent": [ - "FxVersion/4.6.29518.01", + "FxVersion/4.6.30411.01", "OSName/Windows", - "OSVersion/Microsoft.Windows.10.0.19042.", - "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.11.0.0" + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.13.2.0" ] }, "ResponseHeaders": { @@ -405,22 +531,22 @@ "no-cache" ], "Location": [ - "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzYwMzItV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-10-01" + "https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzM5ODYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2021-04-01" ], "Retry-After": [ "0" ], "x-ms-ratelimit-remaining-subscription-reads": [ - "11991" + "11995" ], "x-ms-request-id": [ - "e1bc4687-7b14-4e00-b192-9180de3c932c" + "b562d4d0-3498-4662-9cb5-6b5300f46654" ], "x-ms-correlation-request-id": [ - "e1bc4687-7b14-4e00-b192-9180de3c932c" + "b562d4d0-3498-4662-9cb5-6b5300f46654" ], "x-ms-routing-request-id": [ - "SOUTHEASTASIA:20210202T094609Z:e1bc4687-7b14-4e00-b192-9180de3c932c" + "SOUTHEASTASIA:20211111T084528Z:b562d4d0-3498-4662-9cb5-6b5300f46654" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -429,7 +555,7 @@ "nosniff" ], "Date": [ - "Tue, 02 Feb 2021 09:46:09 GMT" + "Thu, 11 Nov 2021 08:45:27 GMT" ], "Expires": [ "-1" @@ -442,16 +568,19 @@ "StatusCode": 202 }, { - "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzYwMzItV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-10-01", - "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVXpZd016SXRWMFZUVkZWVE1pSXNJbXB2WWt4dlkyRjBhVzl1SWpvaWQyVnpkSFZ6TWlKOT9hcGktdmVyc2lvbj0yMDIwLTEwLTAx", + "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzM5ODYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2021-04-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVXpNNU9EWXRWMFZUVkZWVE1pSXNJbXB2WWt4dlkyRjBhVzl1SWpvaWQyVnpkSFZ6TWlKOT9hcGktdmVyc2lvbj0yMDIxLTA0LTAx", "RequestMethod": "GET", "RequestBody": "", "RequestHeaders": { + "x-ms-client-request-id": [ + "b23d0a97-be71-4f27-91a4-0dde4e4c0b90" + ], "User-Agent": [ - "FxVersion/4.6.29518.01", + "FxVersion/4.6.30411.01", "OSName/Windows", - "OSVersion/Microsoft.Windows.10.0.19042.", - "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.11.0.0" + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.13.2.0" ] }, "ResponseHeaders": { @@ -462,16 +591,16 @@ "no-cache" ], "x-ms-ratelimit-remaining-subscription-reads": [ - "11990" + "11994" ], "x-ms-request-id": [ - "837c646d-0602-4bbc-a4f0-41eebdf3fd30" + "435ee892-1c77-4e96-8a8a-93ee612d8f9f" ], "x-ms-correlation-request-id": [ - "837c646d-0602-4bbc-a4f0-41eebdf3fd30" + "435ee892-1c77-4e96-8a8a-93ee612d8f9f" ], "x-ms-routing-request-id": [ - "SOUTHEASTASIA:20210202T094625Z:837c646d-0602-4bbc-a4f0-41eebdf3fd30" + "SOUTHEASTASIA:20211111T084543Z:435ee892-1c77-4e96-8a8a-93ee612d8f9f" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -480,7 +609,7 @@ "nosniff" ], "Date": [ - "Tue, 02 Feb 2021 09:46:24 GMT" + "Thu, 11 Nov 2021 08:45:43 GMT" ], "Expires": [ "-1" @@ -496,16 +625,19 @@ "StatusCode": 200 }, { - "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzYwMzItV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2020-10-01", - "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVXpZd016SXRWMFZUVkZWVE1pSXNJbXB2WWt4dlkyRjBhVzl1SWpvaWQyVnpkSFZ6TWlKOT9hcGktdmVyc2lvbj0yMDIwLTEwLTAx", + "RequestUri": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1QUzM5ODYtV0VTVFVTMiIsImpvYkxvY2F0aW9uIjoid2VzdHVzMiJ9?api-version=2021-04-01", + "EncodedRequestUri": "L3N1YnNjcmlwdGlvbnMvOWUyMjNkYmUtMzM5OS00ZTE5LTg4ZWItMDk3NWYwMmFjODdmL29wZXJhdGlvbnJlc3VsdHMvZXlKcWIySkpaQ0k2SWxKRlUwOVZVa05GUjFKUFZWQkVSVXhGVkVsUFRrcFBRaTFRVXpNNU9EWXRWMFZUVkZWVE1pSXNJbXB2WWt4dlkyRjBhVzl1SWpvaWQyVnpkSFZ6TWlKOT9hcGktdmVyc2lvbj0yMDIxLTA0LTAx", "RequestMethod": "GET", "RequestBody": "", "RequestHeaders": { + "x-ms-client-request-id": [ + "b23d0a97-be71-4f27-91a4-0dde4e4c0b90" + ], "User-Agent": [ - "FxVersion/4.6.29518.01", + "FxVersion/4.6.30411.01", "OSName/Windows", - "OSVersion/Microsoft.Windows.10.0.19042.", - "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.11.0.0" + "OSVersion/Microsoft.Windows.10.0.19043.", + "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient/3.13.2.0" ] }, "ResponseHeaders": { @@ -516,16 +648,16 @@ "no-cache" ], "x-ms-ratelimit-remaining-subscription-reads": [ - "11989" + "11993" ], "x-ms-request-id": [ - "a4cd3ad0-79f5-498b-8cd6-05637636685c" + "a502a5dc-0283-451d-bd94-5c8ba0dd7fc1" ], "x-ms-correlation-request-id": [ - "a4cd3ad0-79f5-498b-8cd6-05637636685c" + "a502a5dc-0283-451d-bd94-5c8ba0dd7fc1" ], "x-ms-routing-request-id": [ - "SOUTHEASTASIA:20210202T094625Z:a4cd3ad0-79f5-498b-8cd6-05637636685c" + "SOUTHEASTASIA:20211111T084544Z:a502a5dc-0283-451d-bd94-5c8ba0dd7fc1" ], "Strict-Transport-Security": [ "max-age=31536000; includeSubDomains" @@ -534,7 +666,7 @@ "nosniff" ], "Date": [ - "Tue, 02 Feb 2021 09:46:25 GMT" + "Thu, 11 Nov 2021 08:45:44 GMT" ], "Expires": [ "-1" @@ -552,8 +684,8 @@ ], "Names": { "Test-TestDeploymentFromBicepFile": [ - "ps6032", - "ps476" + "ps3986", + "ps974" ] }, "Variables": { diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/ActiveDirectoryBaseCmdlet.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/ActiveDirectoryBaseCmdlet.cs deleted file mode 100644 index b2df63e7faa1..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/ActiveDirectoryBaseCmdlet.cs +++ /dev/null @@ -1,117 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Commands.ResourceManager.Common; -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using System; -using System.Management.Automation; -using System.Net; -using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - [GenericBreakingChange("This cmdlet will use Microsoft Graph in Az 7.x and later., Visit https://go.microsoft.com/fwlink/?linkid=2174792 for migration guide and breaking changes.")] - public abstract class ActiveDirectoryBaseCmdlet : AzureRMCmdlet - { - private ActiveDirectoryClient _activeDirectoryClient; - - public ActiveDirectoryClient ActiveDirectoryClient - { - get - { - if (_activeDirectoryClient == null) - { - _activeDirectoryClient = new ActiveDirectoryClient(DefaultProfile.DefaultContext); - } - - return _activeDirectoryClient; - } - - set { _activeDirectoryClient = value; } - } - - /// - /// Handles graph exceptions thrown by client - /// - /// - private void HandleException(Exception exception) - { - Exception targetEx = exception; - string targetErrorId = String.Empty; - ErrorCategory targetErrorCategory = ErrorCategory.NotSpecified; - var graphEx = exception as GraphErrorException; - - if (graphEx == null) - { - throw exception; - } - - if (graphEx.Body != null && graphEx.Body.Message != null && graphEx.Body.Code != null) - { - WriteDebug(String.Format(ProjectResources.GraphException, graphEx.Body.Code, graphEx.Body.Message)); - targetEx = new Exception(graphEx.Body.Message); - targetErrorId = graphEx.Body.Code; - } - else - { - if (graphEx.Response != null && graphEx.Response.StatusCode == HttpStatusCode.NotFound) - { - targetErrorCategory = ErrorCategory.InvalidArgument; - } - else - { - targetErrorCategory = ErrorCategory.InvalidOperation; - } - - Exception parsedException = ParseResponse(graphEx); - targetEx = parsedException ?? targetEx; - } - - var errorRecord = new ErrorRecord(targetEx, targetErrorId, targetErrorCategory, null); - WriteError(errorRecord); - } - - - private Exception ParseResponse(GraphErrorException graphEx) - { - if (graphEx?.Response?.Content != null) - { - int exceptionMessageIndex = graphEx.Response.Content.IndexOf("\"value\":", StringComparison.CurrentCultureIgnoreCase); - if (exceptionMessageIndex > 0) - { - string substring = graphEx.Response.Content.Substring(exceptionMessageIndex + 9); - // the start index is added 9, so as to remove the delimiter \"value\":\ - string exceptionDetails = substring.Substring(0, substring.IndexOf("\"}")); - return new Exception(exceptionDetails); - } - } - - return null; - } - - protected void ExecutionBlock(Action execAction) - { - try - { - execAction(); - } - catch (Exception exception) - { - WriteDebug(String.Format(ProjectResources.ExceptionInExecution, exception.GetType())); - HandleException(exception); - } - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/AddAzureADGroupMemberCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/AddAzureADGroupMemberCommand.cs deleted file mode 100644 index 65ee58fa0edf..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/AddAzureADGroupMemberCommand.cs +++ /dev/null @@ -1,106 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Commands.Common.Authentication.Abstractions; -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Collections.Generic; -using System.Management.Automation; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Adds a user to a group. - /// - [Cmdlet("Add", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADGroupMember", SupportsShouldProcess = true, DefaultParameterSetName = ParameterSet.MemberObjectIdWithGroupObjectId), OutputType(typeof(bool))] - public class AddAzureADGroupMemberCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberObjectIdWithGroupDisplayName, HelpMessage = "The object id of the member(s) to add to the group.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberObjectIdWithGroupObject, HelpMessage = "The object id of the member(s) to add to the group.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberObjectIdWithGroupObjectId, HelpMessage = "The object id of the member(s) to add to the group.")] - [ValidateNotNullOrEmpty] - public string[] MemberObjectId { get; set; } - - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberUPNWithGroupDisplayName, HelpMessage = "The UPN of the member(s) to add to the group.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberUPNWithGroupObject, HelpMessage = "The UPN of the member(s) to add to the group.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberUPNWithGroupObjectId, HelpMessage = "The UPN of the member(s) to add to the group.")] - public string[] MemberUserPrincipalName { get; set; } - - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberObjectIdWithGroupObjectId, HelpMessage = "The object id of the group to add the member(s) to.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberUPNWithGroupObjectId, HelpMessage = "The object id of the group to add the member(s) to.")] - [ValidateNotNullOrEmpty] - public string TargetGroupObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.MemberObjectIdWithGroupObject, HelpMessage = "The object representation of the group to add the member(s) to.")] - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.MemberUPNWithGroupObject, HelpMessage = "The object representation of the group to add the member(s) to.")] - [ValidateNotNullOrEmpty] - public PSADGroup TargetGroupObject { get; set; } - - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberObjectIdWithGroupDisplayName, HelpMessage = "The display name of the group to add the member(s) to.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberUPNWithGroupDisplayName, HelpMessage = "The display name of the group to add the member(s) to.")] - public string TargetGroupDisplayName { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter PassThru { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.TargetGroupObject)) - { - TargetGroupObjectId = TargetGroupObject.Id; - } - else if (this.IsParameterBound(c => c.TargetGroupDisplayName)) - { - var targetGroup = ActiveDirectoryClient.GetGroupByDisplayName(TargetGroupDisplayName); - TargetGroupObjectId = targetGroup.Id; - } - - if (this.IsParameterBound(c => c.MemberUserPrincipalName)) - { - var memberObjectId = new List(); - foreach (var memberUPN in MemberUserPrincipalName) - { - memberObjectId.Add(ActiveDirectoryClient.GetObjectIdFromUPN(memberUPN)); - } - - MemberObjectId = memberObjectId.ToArray(); - } - - foreach (var memberObjectId in MemberObjectId) - { - var groupAddMemberParams = new GroupAddMemberParameters() - { - Url = string.Format("{0}{1}/directoryObjects/{2}", - AzureEnvironmentConstants.AzureGraphEndpoint, - AzureRmProfileProvider.Instance.Profile.DefaultContext.Tenant.Id, - memberObjectId) - }; - - if (ShouldProcess(target: memberObjectId.ToString(), action: string.Format("Adding user with object id '{0}' to group with object id '{1}'.", memberObjectId, TargetGroupObjectId))) - { - ActiveDirectoryClient.AddGroupMember(TargetGroupObjectId.ToString(), groupAddMemberParams); - } - } - - if (PassThru.IsPresent) - { - WriteObject(true); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADAppCredentialCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADAppCredentialCommand.cs deleted file mode 100644 index d01a53c353e2..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADAppCredentialCommand.cs +++ /dev/null @@ -1,66 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Management.Automation; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Gets AD application credentials. - /// - [CmdletOutputBreakingChange(typeof(PSADCredential), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphKeyCredential, Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordCredential")] - [Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADAppCredential", DefaultParameterSetName = ParameterSet.ApplicationObjectId), OutputType(typeof(PSADCredential))] - public class GetAzureADAppCredentialCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectId, HelpMessage = "The application object id.")] - [ValidateNotNullOrEmpty] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationId, HelpMessage = "The application id.")] - [ValidateNotNullOrEmpty] - public Guid ApplicationId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayName, HelpMessage = "The display name of the application.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ApplicationObject, HelpMessage = "The application object.")] - [ValidateNotNullOrEmpty] - public PSADApplication ApplicationObject { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.ApplicationObject)) - { - ObjectId = ApplicationObject.ObjectId; - } - else if (this.IsParameterBound(c => c.ApplicationId)) - { - ObjectId = ActiveDirectoryClient.GetAppObjectIdFromApplicationId(ApplicationId); - } - else if (this.IsParameterBound(c => c.DisplayName)) - { - ObjectId = ActiveDirectoryClient.GetAppObjectIdFromDisplayName(DisplayName); - } - - WriteObject(ActiveDirectoryClient.GetAppCredentials(ObjectId), enumerateCollection: true); - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADApplicationCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADApplicationCommand.cs deleted file mode 100644 index b8aef5b15a6d..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADApplicationCommand.cs +++ /dev/null @@ -1,88 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Collections.Generic; -using System.Management.Automation; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Gets the AD application. - /// - [CmdletOutputBreakingChange(typeof(PSADApplication), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphApplication")] - [Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADApplication", DefaultParameterSetName = ParameterSet.Empty, SupportsPaging = true), OutputType(typeof(PSADApplication))] - public class GetAzureADApplicationCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectId, HelpMessage = "The application object id.")] - [ValidateNotNullOrEmpty] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationId, HelpMessage = "The application id.")] - [ValidateGuidNotEmpty] - public Guid ApplicationId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SearchString, HelpMessage = "Used to find applications that begin with the provided string.")] - [ValidateNotNullOrEmpty] - public string DisplayNameStartWith { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayName, HelpMessage = "The display name of the application.")] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdentifierUri, HelpMessage = "The identifierUri of the application.")] - [ValidateNotNullOrEmpty] - public string IdentifierUri { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.ObjectId)) - { - WriteObject(ActiveDirectoryClient.GetApplication(ObjectId)); - } - else - { - Rest.Azure.OData.ODataQuery odataQueryFilter = new Rest.Azure.OData.ODataQuery(); - - if (this.IsParameterBound(c => c.ApplicationId)) - { - string appId = ApplicationId.ToString(); - odataQueryFilter = new Rest.Azure.OData.ODataQuery(a => a.AppId == appId); - } - else if (this.IsParameterBound(c => c.DisplayNameStartWith)) - { - odataQueryFilter = new Rest.Azure.OData.ODataQuery(a => a.DisplayName.StartsWith(DisplayNameStartWith)); - } - else if (this.IsParameterBound(c => c.IdentifierUri)) - { - odataQueryFilter = new Rest.Azure.OData.ODataQuery(a => a.IdentifierUris.Contains(IdentifierUri)); - } - else if (this.IsParameterBound(c => c.DisplayName)) - { - odataQueryFilter = new Rest.Azure.OData.ODataQuery(a => a.DisplayName == DisplayName); - } - - ulong first = MyInvocation.BoundParameters.ContainsKey("First") ? this.PagingParameters.First : ulong.MaxValue; - ulong skip = MyInvocation.BoundParameters.ContainsKey("Skip") ? this.PagingParameters.Skip : 0; - WriteObject(ActiveDirectoryClient.GetApplicationWithFilters(odataQueryFilter, first, skip), enumerateCollection: true); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADGroupCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADGroupCommand.cs deleted file mode 100644 index 95f55b54b4b5..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADGroupCommand.cs +++ /dev/null @@ -1,63 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Collections.Generic; -using System.Management.Automation; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Get AD groups. - /// - [CmdletOutputBreakingChange(typeof(PSADGroup), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphGroup")] - [Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADGroup", DefaultParameterSetName = ParameterSet.Empty, SupportsPaging = true), OutputType(typeof(PSADGroup))] - public class GetAzureADGroupCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SearchString, - HelpMessage = "Used to find groups that begin with the provided string.")] - [Alias("SearchString")] - [ValidateNotNullOrEmpty] - public string DisplayNameStartsWith { get; set; } - - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.DisplayName, HelpMessage = "The display name of the group.")] - public string DisplayName { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.Empty, - HelpMessage = "The group id.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, - HelpMessage = "The group id.")] - [ValidateNotNullOrEmpty] - public Guid ObjectId { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - ADObjectFilterOptions options = new ADObjectFilterOptions - { - SearchString = this.IsParameterBound(c => c.DisplayNameStartsWith) ? DisplayNameStartsWith + "*" : DisplayName, - Id = ObjectId == Guid.Empty ? null : ObjectId.ToString(), - Paging = true - }; - - ulong first = MyInvocation.BoundParameters.ContainsKey("First") ? this.PagingParameters.First : ulong.MaxValue; - ulong skip = MyInvocation.BoundParameters.ContainsKey("Skip") ? this.PagingParameters.Skip : 0; - WriteObject(ActiveDirectoryClient.FilterGroups(options, first, skip), true); - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADGroupMemberCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADGroupMemberCommand.cs deleted file mode 100644 index 3a2ab839d085..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADGroupMemberCommand.cs +++ /dev/null @@ -1,77 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Management.Automation; -using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Get AD groups members. - /// - [CmdletOutputBreakingChange(typeof(PSADObject), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphDirectoryObject")] - [Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADGroupMember", DefaultParameterSetName = ParameterSet.ObjectId, SupportsPaging = true), OutputType(typeof(PSADObject))] - public class GetAzureADGroupMemberCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, HelpMessage = "Object Id of the group.")] - [ValidateNotNullOrEmpty] - [Alias("Id", "ObjectId")] - public string GroupObjectId { get; set; } - - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.DisplayName, HelpMessage = "The display name of the group.")] - [ValidateNotNullOrEmpty] - public string GroupDisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.GroupObject, HelpMessage = "The group object.")] - [ValidateNotNullOrEmpty] - public PSADGroup GroupObject { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.GroupObject)) - { - GroupObjectId = GroupObject.Id; - } - else if (this.IsParameterBound(c => c.GroupDisplayName)) - { - var targetGroup = ActiveDirectoryClient.GetGroupByDisplayName(GroupDisplayName); - GroupObjectId = targetGroup.Id; - } - - ADObjectFilterOptions options = new ADObjectFilterOptions - { - Id = GroupObjectId, - Paging = true - }; - - PSADObject group = ActiveDirectoryClient.FilterGroups(options).FirstOrDefault(); - if (group == null) - { - throw new KeyNotFoundException(string.Format(ProjectResources.GroupDoesntExist, GroupObjectId)); - } - - ulong first = MyInvocation.BoundParameters.ContainsKey("First") ? this.PagingParameters.First : ulong.MaxValue; - ulong skip = MyInvocation.BoundParameters.ContainsKey("Skip") ? this.PagingParameters.Skip : 0; - WriteObject(ActiveDirectoryClient.GetGroupMembers(options, first, skip), true); - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADServicePrincipalCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADServicePrincipalCommand.cs deleted file mode 100644 index 010f0e6c7666..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADServicePrincipalCommand.cs +++ /dev/null @@ -1,108 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Collections.Generic; -using System.Management.Automation; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Get AD users. - /// - [CmdletOutputBreakingChange(typeof(PSADServicePrincipal), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphServicePrincipal")] - [Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADServicePrincipal", DefaultParameterSetName = ParameterSet.Empty, SupportsPaging = true), OutputType(typeof(PSADServicePrincipal))] - public class GetAzureADServicePrincipalCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SearchString, - HelpMessage = "The service principal search string.")] - [Alias("SearchString")] - [ValidateNotNullOrEmpty] - public string DisplayNameBeginsWith { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayName, HelpMessage = "The service principal display name.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, - HelpMessage = "The service principal object id.")] - [ValidateNotNullOrEmpty] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationId, - HelpMessage = "The service principal application id.")] - public Guid ApplicationId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ApplicationObject, - HelpMessage = "The object representing the application to create an service principal for.")] - public PSADApplication ApplicationObject { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SPN, - HelpMessage = "The user SPN.")] - [ValidateNotNullOrEmpty] - [Alias("SPN")] - public string ServicePrincipalName { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.ApplicationObject)) - { - ApplicationId = ApplicationObject.ApplicationId; - } - - if (this.IsParameterBound(c => c.ObjectId)) - { - var objectId = ObjectId; - var servicePrincipal = ActiveDirectoryClient.GetServicePrincipalByObjectId(objectId); - if (servicePrincipal != null) - { - WriteObject(servicePrincipal); - } - } - else if (this.IsParameterBound(c => c.ServicePrincipalName)) - { - var servicePrincipal = ActiveDirectoryClient.GetServicePrincipalBySPN(ServicePrincipalName); - if (servicePrincipal != null) - { - WriteObject(servicePrincipal); - } - } - else - { - ulong first = MyInvocation.BoundParameters.ContainsKey("First") ? this.PagingParameters.First : ulong.MaxValue; - ulong skip = MyInvocation.BoundParameters.ContainsKey("Skip") ? this.PagingParameters.Skip : 0; - if (ApplicationId != Guid.Empty) - { - var appId = ApplicationId.ToString(); - Rest.Azure.OData.ODataQuery odataQuery = new Rest.Azure.OData.ODataQuery(s => s.AppId == appId); - WriteObject(ActiveDirectoryClient.FilterServicePrincipals(odataQuery, first, skip), true); - } - else - { - ADObjectFilterOptions options = new ADObjectFilterOptions() - { - SearchString = this.IsParameterBound(c => c.DisplayNameBeginsWith) ? DisplayNameBeginsWith + "*" : DisplayName - }; - WriteObject(ActiveDirectoryClient.FilterServicePrincipals(options, first, skip), true); - } - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADSpCredentialCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADSpCredentialCommand.cs deleted file mode 100644 index d3811ef4bded..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADSpCredentialCommand.cs +++ /dev/null @@ -1,68 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Management.Automation; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Gets AD service principal credentials. - /// - [CmdletOutputBreakingChange(typeof(PSADCredential), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphKeyCredential, Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordCredential")] - [Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADSpCredential", DefaultParameterSetName = ParameterSet.ObjectId), OutputType(typeof(PSADCredential))] - [Alias("Get-" + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADServicePrincipalCredential")] - public class GetAzureADSpCredentialCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, HelpMessage = "The servicePrincipal object id.")] - [ValidateNotNullOrEmpty] - [Alias("Id")] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SPN, HelpMessage = "The servicePrincipal name.")] - [ValidateNotNullOrEmpty] - public string ServicePrincipalName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayName, HelpMessage = "The display name of the service principal")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.SPNObject, HelpMessage = "The service principal object.")] - [ValidateNotNullOrEmpty] - public PSADServicePrincipal ServicePrincipalObject { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.ServicePrincipalObject)) - { - ObjectId = ServicePrincipalObject.Id; - } - else if (this.IsParameterBound(c => c.ServicePrincipalName)) - { - ObjectId = ActiveDirectoryClient.GetObjectIdFromSPN(ServicePrincipalName); - } - else if (this.IsParameterBound(c => c.DisplayName)) - { - ObjectId = ActiveDirectoryClient.GetObjectIdFromServicePrincipalDisplayName(DisplayName); - } - - WriteObject(ActiveDirectoryClient.GetSpCredentials(ObjectId), enumerateCollection: true); - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADUserCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADUserCommand.cs deleted file mode 100644 index 10a322861ec2..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/GetAzureADUserCommand.cs +++ /dev/null @@ -1,80 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System.Management.Automation; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Get AD users. - /// - [CmdletOutputBreakingChange(typeof(PSADUser), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphUser")] - [Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADUser", DefaultParameterSetName = ParameterSet.Empty, SupportsPaging = true), OutputType(typeof(PSADUser))] - public class GetAzureADUserCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SearchString, - HelpMessage = "Used to find users that begin with the provided string.")] - [Alias("SearchString")] - [ValidateNotNullOrEmpty] - public string StartsWith { get; set; } - - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.DisplayName, HelpMessage = "The display name of the user.")] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, - HelpMessage = "The user object id.")] - [ValidateNotNullOrEmpty] - public string ObjectId { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.Empty, - HelpMessage = "The user UPN.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.UPN, - HelpMessage = "The user UPN.")] - [ValidateNotNullOrEmpty] - [Alias("UPN")] - public string UserPrincipalName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.Mail, - HelpMessage = "The user mail.")] - [ValidateNotNullOrEmpty] - public string Mail { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - ADObjectFilterOptions options = new ADObjectFilterOptions - { - SearchString = this.IsParameterBound(c => c.StartsWith) ? StartsWith + "*" : DisplayName, - UPN = UserPrincipalName, - Id = ObjectId, - Paging = true, - Mail = Mail - }; - if(!string.IsNullOrEmpty(options.SearchString)) - { - //query string is wrapped with single quote. Escape is needed if it contains additional quote. - options.SearchString = options.SearchString.Replace("'", "''"); - } - - - ulong first = MyInvocation.BoundParameters.ContainsKey("First") ? this.PagingParameters.First : ulong.MaxValue; - ulong skip = MyInvocation.BoundParameters.ContainsKey("Skip") ? this.PagingParameters.Skip : 0; - WriteObject(ActiveDirectoryClient.FilterUsers(options, first, skip), true); - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADAppCredentialCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADAppCredentialCommand.cs deleted file mode 100644 index 5d5577dfb26e..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADAppCredentialCommand.cs +++ /dev/null @@ -1,161 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Management.Automation; -using System.Security; -using System.Text; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Creates a new AD application Credential. - /// - [CmdletOutputBreakingChange(typeof(PSADCredential), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphKeyCredential, Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordCredential")] - [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADAppCredential", DefaultParameterSetName = ParameterSet.ApplicationObjectIdWithPassword, SupportsShouldProcess = true), OutputType(typeof(PSADCredential))] - public class NewAzureADAppCredentialCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectIdWithCertValue, HelpMessage = "The application object id.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectIdWithPassword, HelpMessage = "The application object id.")] - [ValidateNotNullOrEmpty] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdWithCertValue, HelpMessage = "The application id.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdWithPassword, HelpMessage = "The application id.")] - [ValidateNotNullOrEmpty] - public Guid ApplicationId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithPassword, HelpMessage = "The display name of the application.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithCertValue, HelpMessage = "The display name of the application.")] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ApplicationObjectWithCertValue, HelpMessage = "The application object.")] - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ApplicationObjectWithPassword, HelpMessage = "The application object.")] - [ValidateNotNullOrEmpty] - public PSADApplication ApplicationObject { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectIdWithPassword, - HelpMessage = "The value for the password credential associated with the application that will be valid for one year by default.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdWithPassword, - HelpMessage = "The value for the password credential associated with the application that will be valid for one year by default.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.ApplicationObjectWithPassword, - HelpMessage = "The value for the password credential associated with the application that will be valid for one year by default.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.DisplayNameWithPassword, - HelpMessage = "The value for the password credential associated with the application that will be valid for one year by default.")] - [ValidateNotNullOrEmpty] - [CmdletParameterBreakingChange("Password", ChangeDescription = "Parameter Password will not be supported, server generated secret text could be found in response")] - public SecureString Password { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectIdWithCertValue, - HelpMessage = "The base64 encoded value for the AsymmetricX509Cert associated with the application that will be valid for one year by default.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdWithCertValue, - HelpMessage = "The base64 encoded value for the AsymmetricX509Cert associated with the application that will be valid for one year by default.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.ApplicationObjectWithCertValue, - HelpMessage = "The base64 encoded value for the AsymmetricX509Cert associated with the application that will be valid for one year by default.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.DisplayNameWithCertValue, - HelpMessage = "The base64 encoded value for the AsymmetricX509Cert associated with the application that will be valid for one year by default.")] - [ValidateNotNullOrEmpty] - public string CertValue { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The start date after which password or key would be valid. Default value is current time.")] - public DateTime StartDate { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The end date till which password or key is valid. Default value is one year after the start date.")] - public DateTime EndDate { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "Custom Key Identifier")] - public String CustomKeyIdentifier { get; set; } - - public Guid KeyId { get; set; } = default(Guid); - - public NewAzureADAppCredentialCommand() - { - DateTime currentTime = DateTime.UtcNow; - StartDate = currentTime; - } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - - if (!this.IsParameterBound(c => c.EndDate)) - { - WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed); - EndDate = StartDate.AddYears(1); - } - - if (this.IsParameterBound(c => c.ApplicationObject)) - { - ObjectId = ApplicationObject.ObjectId; - } - else if (this.IsParameterBound(c => c.ApplicationId)) - { - ObjectId = ActiveDirectoryClient.GetAppObjectIdFromApplicationId(ApplicationId); - } - else if (this.IsParameterBound(c => c.DisplayName)) - { - ObjectId = ActiveDirectoryClient.GetAppObjectIdFromDisplayName(DisplayName); - } - - if (Password != null && Password.Length > 0) - { - string decodedPassword = SecureStringExtensions.ConvertToString(Password); - // Create object for password credential - var passwordCredential = new PasswordCredential() - { - EndDate = EndDate, - StartDate = StartDate, - KeyId = KeyId == default(Guid) ? Guid.NewGuid().ToString() : KeyId.ToString(), - Value = decodedPassword - }; - if(!String.IsNullOrEmpty(CustomKeyIdentifier)) - { - passwordCredential.CustomKeyIdentifier = Encoding.UTF8.GetBytes(CustomKeyIdentifier); - } - if (ShouldProcess(target: ObjectId, action: string.Format("Adding a new password to application with objectId {0}", ObjectId))) - { - WriteObject(ActiveDirectoryClient.CreateAppPasswordCredential(ObjectId, passwordCredential)); - } - } - else if (CertValue != null) - { - // Create object for key credential - var keyCredential = new KeyCredential() - { - EndDate = EndDate, - StartDate = StartDate, - KeyId = KeyId == default(Guid) ? Guid.NewGuid().ToString() : KeyId.ToString(), - Value = CertValue, - Type = "AsymmetricX509Cert", - Usage = "Verify", - CustomKeyIdentifier = CustomKeyIdentifier - }; - if (ShouldProcess(target: ObjectId, action: string.Format("Adding a new certificate to application with objectId {0}", ObjectId))) - { - WriteObject(ActiveDirectoryClient.CreateAppKeyCredential(ObjectId, keyCredential)); - } - } - else - { - throw new InvalidOperationException("No valid keyCredential or passwordCredential to update!!"); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADApplicationCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADApplicationCommand.cs deleted file mode 100644 index 95a7360dba2a..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADApplicationCommand.cs +++ /dev/null @@ -1,197 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Management.Automation; -using System.Security; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Creates a new AD application. - /// - [CmdletOutputBreakingChange(typeof(PSADApplication), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphApplication")] - [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADApplication", DefaultParameterSetName = ParameterSet.ApplicationWithoutCredential, SupportsShouldProcess = true), OutputType(typeof(PSADApplication))] - public class NewAzureADApplicationCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithoutCredential, - HelpMessage = "The display name for the application.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordPlain, - HelpMessage = "The display name for the application.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordCredential, - HelpMessage = "The display name for the application.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyPlain, - HelpMessage = "The display name for the application.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyCredential, - HelpMessage = "The display name for the application.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithoutCredential, - HelpMessage = "The URIs that identify the application.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordPlain, - HelpMessage = "The URIs that identify the application.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordCredential, - HelpMessage = "The URIs that identify the application.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyPlain, - HelpMessage = "The URIs that identify the application.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyCredential, - HelpMessage = "The URIs that identify the application.")] - [ValidateNotNullOrEmpty] - [Alias("IdentifierUris")] - public string[] IdentifierUri { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithoutCredential, - HelpMessage = "The URL to the application’s homepage.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordPlain, - HelpMessage = "The URL to the application’s homepage.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordCredential, - HelpMessage = "The URL to the application’s homepage.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyPlain, - HelpMessage = "The URL to the application’s homepage.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyCredential, - HelpMessage = "The URL to the application’s homepage.")] - [ValidateNotNullOrEmpty] - public string HomePage { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithoutCredential, - HelpMessage = "Specifies the URLs that user tokens are sent to for sign in, or the redirect URIs that OAuth 2.0 authorization codes and access tokens are sent to.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordPlain, - HelpMessage = "Specifies the URLs that user tokens are sent to for sign in, or the redirect URIs that OAuth 2.0 authorization codes and access tokens are sent to.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordCredential, - HelpMessage = "Specifies the URLs that user tokens are sent to for sign in, or the redirect URIs that OAuth 2.0 authorization codes and access tokens are sent to.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyPlain, - HelpMessage = "Specifies the URLs that user tokens are sent to for sign in, or the redirect URIs that OAuth 2.0 authorization codes and access tokens are sent to.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyCredential, - HelpMessage = "Specifies the URLs that user tokens are sent to for sign in, or the redirect URIs that OAuth 2.0 authorization codes and access tokens are sent to.")] - [ValidateNotNullOrEmpty] - public string[] ReplyUrls { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithoutCredential, - HelpMessage = "True if the application is shared with other tenants; otherwise, false.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordPlain, - HelpMessage = "True if the application is shared with other tenants; otherwise, false.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordCredential, - HelpMessage = "True if the application is shared with other tenants; otherwise, false.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyPlain, - HelpMessage = "True if the application is shared with other tenants; otherwise, false.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyCredential, - HelpMessage = "True if the application is shared with other tenants; otherwise, false.")] - public bool AvailableToOtherTenants { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordCredential, - HelpMessage = "The collection of password credentials associated with the application.")] - public PSADPasswordCredential[] PasswordCredentials { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyCredential, - HelpMessage = "The collection of key credentials associated with the application.")] - public PSADKeyCredential[] KeyCredentials { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordPlain, - HelpMessage = "The value for the password credential associated with the application that will be valid for one year by default.")] - [ValidateNotNullOrEmpty] - [CmdletParameterBreakingChange("Password", ChangeDescription = "Parameter Password will not be supported, server generated secret text could be found in response")] - public SecureString Password { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyPlain, - HelpMessage = "The base64 encoded cert value for the key credentials associated with the application that will be valid for one year by default.")] - [ValidateNotNullOrEmpty] - public string CertValue { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordPlain, - HelpMessage = "The start date after which password or key would be valid. Default value is current time.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyPlain, - HelpMessage = "The start date after which password or key would be valid. Default value is current time.")] - public DateTime StartDate { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordPlain, - HelpMessage = "The end date till which password or key is valid. Default value is one year after current time.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyPlain, - HelpMessage = "The end date till which password or key is valid. Default value is one year after current time.")] - public DateTime EndDate { get; set; } - - public NewAzureADApplicationCommand() - { - DateTime currentTime = DateTime.UtcNow; - StartDate = currentTime; - } - - public override void ExecuteCmdlet() - { - if (!this.IsParameterBound(c => c.EndDate)) - { - WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed); - EndDate = StartDate.AddYears(1); - } - - CreatePSApplicationParameters createParameters = new CreatePSApplicationParameters - { - DisplayName = DisplayName, - HomePage = HomePage, - IdentifierUris = (IdentifierUri == null) ? new string[] { } : IdentifierUri, - ReplyUrls = ReplyUrls, - AvailableToOtherTenants = AvailableToOtherTenants - }; - - switch (ParameterSetName) - { - case ParameterSet.ApplicationWithPasswordPlain: - string decodedPassword = SecureStringExtensions.ConvertToString(Password); - createParameters.PasswordCredentials = new PSADPasswordCredential[] - { - new PSADPasswordCredential - { - StartDate = StartDate, - EndDate = EndDate, - KeyId = Guid.NewGuid(), - Password = decodedPassword - } - }; - break; - - case ParameterSet.ApplicationWithPasswordCredential: - createParameters.PasswordCredentials = PasswordCredentials; - break; - - case ParameterSet.ApplicationWithKeyPlain: - createParameters.KeyCredentials = new PSADKeyCredential[] - { - new PSADKeyCredential - { - StartDate = StartDate, - EndDate = EndDate, - KeyId = Guid.NewGuid(), - CertValue = CertValue - } - }; - break; - - case ParameterSet.ApplicationWithKeyCredential: - createParameters.KeyCredentials = KeyCredentials; - break; - } - - ExecutionBlock(() => - { - if (ShouldProcess(target: createParameters.DisplayName, action: string.Format("Adding a new application with display name '{0}'", createParameters.DisplayName))) - { - WriteObject(ActiveDirectoryClient.CreateApplication(createParameters)); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADGroupCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADGroupCommand.cs deleted file mode 100644 index c97b27283967..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADGroupCommand.cs +++ /dev/null @@ -1,62 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using System.Management.Automation; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Creates a new AD group. - /// - [CmdletOutputBreakingChange(typeof(PSADGroup), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphGroup")] - [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADGroup", SupportsShouldProcess = true), OutputType(typeof(PSADGroup))] - public class NewAzureADGroupCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The display name for the group.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The mail nickname for the group.")] - [ValidateNotNullOrEmpty] - public string MailNickname { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The description for the group.")] - public string Description { get; set; } - - public override void ExecuteCmdlet() - { - var groupCreateParams = new GroupCreateParameters() - { - DisplayName = DisplayName, - MailNickname = MailNickname, - AdditionalProperties = new System.Collections.Generic.Dictionary() - }; - - if (!string.IsNullOrEmpty(Description)) - { - groupCreateParams.AdditionalProperties.Add("description", Description); - } - - ExecutionBlock(() => - { - if (ShouldProcess(target: DisplayName, action: string.Format("Creating a new AD group with display name '{0}'", DisplayName))) - { - WriteObject(ActiveDirectoryClient.CreateGroup(groupCreateParams)); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADServicePrincipalCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADServicePrincipalCommand.cs deleted file mode 100644 index 89f4ef051a76..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADServicePrincipalCommand.cs +++ /dev/null @@ -1,411 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; -using Microsoft.Azure.Commands.Resources.Models; -using Microsoft.Azure.Commands.Resources.Models.Authorization; -using Microsoft.Azure.Management.Authorization.Models; -using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Management.Automation; -using System.Web; -using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Creates a new service principal. - /// - [CmdletOutputBreakingChange(typeof(PSADServicePrincipal), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphServicePrincipal")] - [CmdletOutputBreakingChange(typeof(PSADServicePrincipalWrapper), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphServicePrincipal")] - [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADServicePrincipal", DefaultParameterSetName = "SimpleParameterSet", SupportsShouldProcess = true)] - [OutputType(typeof(PSADServicePrincipal), typeof(PSADServicePrincipalWrapper))] - public class NewAzureADServicePrincipalCommand : ActiveDirectoryBaseCmdlet - { - private const string SimpleParameterSet = "SimpleParameterSet"; - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithoutCredential, - HelpMessage = "The application id for which service principal is created.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordPlain, - HelpMessage = "The application id for which service principal is created.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordCredential, - HelpMessage = "The application id for which service principal is created.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyPlain, - HelpMessage = "The application id for which service principal is created.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyCredential, - HelpMessage = "The application id for which service principal is created.")] - [Parameter(Mandatory = false, ParameterSetName = SimpleParameterSet, HelpMessage = "The application id for which service principal is created.")] - public Guid ApplicationId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithoutCredential, - HelpMessage = "The display name for the application.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithPasswordPlain, - HelpMessage = "The display name for the application.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithPasswordCredential, - HelpMessage = "The display name for the application.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithKeyPlain, - HelpMessage = "The display name for the application.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithKeyCredential, - HelpMessage = "The display name for the application.")] - [Parameter(Mandatory = false, ParameterSetName = SimpleParameterSet, HelpMessage = "The display name for the service principal is derived from the IdentifierUris of created application.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ApplicationObjectWithPasswordPlain, - HelpMessage = "The object representing the application for which the service principal is created.")] - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ApplicationObjectWithPasswordCredential, - HelpMessage = "The object representing the application for which the service principal is created.")] - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ApplicationObjectWithKeyPlain, - HelpMessage = "The object representing the application for which the service principal is created.")] - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ApplicationObjectWithKeyCredential, - HelpMessage = "The object representing the application for which the service principal is created.")] - public PSADApplication ApplicationObject { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordCredential, - HelpMessage = "The collection of password credentials associated with the application.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithPasswordCredential, - HelpMessage = "The collection of password credentials associated with the application.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.ApplicationObjectWithPasswordCredential, - HelpMessage = "The collection of password credentials associated with the application.")] - [Alias("PasswordCredentials")] - public PSADPasswordCredential[] PasswordCredential { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyCredential, - HelpMessage = "The collection of key credentials associated with the application.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithKeyCredential, - HelpMessage = "The collection of key credentials associated with the application.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.ApplicationObjectWithKeyCredential, - HelpMessage = "The collection of key credentials associated with the application.")] - [Alias("KeyCredentials")] - public PSADKeyCredential[] KeyCredential { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyPlain, - HelpMessage = "The base64 encoded cert value for the key credentials associated with the application that will be valid for one year by default.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithKeyPlain, - HelpMessage = "The base64 encoded cert value for the key credentials associated with the application that will be valid for one year by default.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.ApplicationObjectWithKeyPlain, - HelpMessage = "The base64 encoded cert value for the key credentials associated with the application that will be valid for one year by default.")] - [ValidateNotNullOrEmpty] - public string CertValue { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordPlain, - HelpMessage = "The start date after which password or key would be valid. Default value is current time.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyPlain, - HelpMessage = "The start date after which password or key would be valid. Default value is current time.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithPasswordPlain, - HelpMessage = "The start date after which password or key would be valid. Default value is current time.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithKeyPlain, - HelpMessage = "The start date after which password or key would be valid. Default value is current time.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.ApplicationObjectWithPasswordPlain, - HelpMessage = "The start date after which password or key would be valid. Default value is current time.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.ApplicationObjectWithKeyPlain, - HelpMessage = "The start date after which password or key would be valid. Default value is current time.")] - [Parameter(Mandatory = false, ParameterSetName = SimpleParameterSet, - HelpMessage = "The start date after which password or key would be valid. Default value is current time.")] - public DateTime StartDate { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithPasswordPlain, - HelpMessage = "The end date till which password or key is valid. Default value is one year after current time.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationWithKeyPlain, - HelpMessage = "The end date till which password or key is valid. Default value is one year after current time.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithPasswordPlain, - HelpMessage = "The end date till which password or key is valid. Default value is one year after current time.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithKeyPlain, - HelpMessage = "The end date till which password or key is valid. Default value is one year after current time.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.ApplicationObjectWithPasswordPlain, - HelpMessage = "The end date till which password or key is valid. Default value is one year after current time.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.ApplicationObjectWithKeyPlain, - HelpMessage = "The end date till which password or key is valid. Default value is one year after current time.")] - [Parameter(Mandatory = false, ParameterSetName = SimpleParameterSet, - HelpMessage = "The end date till which password or key is valid. Default value is one year after the start date.")] - public DateTime EndDate { get; set; } - - [Parameter(Mandatory = false, ParameterSetName = SimpleParameterSet, HelpMessage = "The scope that the service principal has permissions on. If a value for Role is provided, but " + - "no value is provided for Scope, then Scope will default to the current subscription.")] - [ScopeCompleter] - public string Scope { get; set; } - - [Parameter(Mandatory = false, ParameterSetName = SimpleParameterSet, HelpMessage = "The role that the service principal has over the scope. If a value for Scope is provided, but " + - "no value is provided for Role, then Role will default to the 'Contributor' role.")] - [PSArgumentCompleter("Reader", "Contributor", "Owner")] - public string Role { get; set; } - - [Parameter(Mandatory = false, ParameterSetName = SimpleParameterSet, HelpMessage = "If set, will skip creating the default role assignment for the service principal.")] - public SwitchParameter SkipAssignment { get; set; } - - private AuthorizationClient _policiesClient; - - public AuthorizationClient PoliciesClient - { - get - { - if (this._policiesClient == null) - { - this._policiesClient = new AuthorizationClient(DefaultContext); - } - - return this._policiesClient; - } - - set { this._policiesClient = value; } - } - - public NewAzureADServicePrincipalCommand() - { - DateTime currentTime = DateTime.UtcNow; - StartDate = currentTime; - } - - public override void ExecuteCmdlet() - { - WriteWarningWithTimestamp("New-AzAdServicePrincipal will no longer assign role 'Contributor' to new created service principal by default"); - ExecutionBlock(() => - { - //safe gauard for login status, check if DefaultContext not existed, PSInvalidOperationException will be thrown - var CheckDefaultContext = DefaultContext; - - if (this.ParameterSetName == SimpleParameterSet) - { - CreateSimpleServicePrincipal(); - return; - } - - if (!this.IsParameterBound(c => c.EndDate)) - { - WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed); - EndDate = StartDate.AddYears(1); - } - - if (this.IsParameterBound(c => c.ApplicationObject)) - { - ApplicationId = ApplicationObject.ApplicationId; - DisplayName = ApplicationObject.DisplayName; - } - - if (ApplicationId == Guid.Empty) - { - - - // Create an application and get the applicationId - CreatePSApplicationParameters appParameters = new CreatePSApplicationParameters(); - - if(this.IsParameterBound(c => c.DisplayName) && !string.IsNullOrEmpty(DisplayName)) - { - string uri = "http://" + HttpUtility.UrlEncode(DisplayName.Trim()); - appParameters.IdentifierUris = new string[] { }; - appParameters.DisplayName = DisplayName; - } - - if (this.IsParameterBound(c => c.PasswordCredential)) - { - appParameters.PasswordCredentials = PasswordCredential; - } - else if (this.IsParameterBound(c => c.CertValue)) - { - appParameters.KeyCredentials = new PSADKeyCredential[] - { - new PSADKeyCredential - { - StartDate = StartDate, - EndDate = EndDate, - KeyId = Guid.NewGuid(), - CertValue = CertValue - } - }; - } - else if (this.IsParameterBound(c => c.KeyCredential)) - { - appParameters.KeyCredentials = KeyCredential; - } - - if (ShouldProcess(target: appParameters.DisplayName, action: string.Format("Adding a new application for with display name '{0}'", appParameters.DisplayName))) - { - var application = ActiveDirectoryClient.CreateApplication(appParameters); - ApplicationId = application.ApplicationId; - } - } - - CreatePSServicePrincipalParameters createParameters = new CreatePSServicePrincipalParameters - { - ApplicationId = ApplicationId, - AccountEnabled = true - }; - - if (ShouldProcess(target: createParameters.ApplicationId.ToString(), action: string.Format("Adding a new service principal to be associated with an application having AppId '{0}'", createParameters.ApplicationId))) - { - var servicePrincipal = ActiveDirectoryClient.CreateServicePrincipal(createParameters); - WriteObject(servicePrincipal); - } - }); - } - - private void CreateSimpleServicePrincipal() - { - var subscriptionId = DefaultContext.Subscription?.Id; - if (!this.IsParameterBound(c => c.StartDate)) - { - DateTime currentTime = DateTime.UtcNow; - StartDate = currentTime; - WriteVerbose("No start date provided - using the current time as default."); - } - - if (!this.IsParameterBound(c => c.EndDate)) - { - EndDate = StartDate.AddYears(1); - WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed); - } - - if (!this.IsParameterBound(c => c.DisplayName)) - { - DisplayName = "azure-powershell-" + StartDate.ToString("MM-dd-yyyy-HH-mm-ss"); - WriteVerbose(string.Format("No display name provided - using the default display name of '{0}'", DisplayName)); - } - - bool printPassword = false; - bool printUseExistingSecret = true; - - // Handle credentials - var Password = Guid.NewGuid().ToString().ConvertToSecureString(); - - // Create an application and get the applicationId - if (!this.IsParameterBound(c => c.ApplicationId)) - { - printUseExistingSecret = false; - CreatePSApplicationParameters appParameters = new CreatePSApplicationParameters - { - DisplayName = DisplayName, - HomePage = "http://" + HttpUtility.UrlEncode(DisplayName.Trim()), - PasswordCredentials = new PSADPasswordCredential[] - { - new PSADPasswordCredential() - { - StartDate = StartDate, - EndDate = EndDate, - KeyId = Guid.NewGuid(), - Password = SecureStringExtensions.ConvertToString(Password) - } - } - }; - - if (ShouldProcess(target: appParameters.DisplayName, action: string.Format("Adding a new application for with display name '{0}'", appParameters.DisplayName))) - { - var application = ActiveDirectoryClient.CreateApplication(appParameters); - ApplicationId = application.ApplicationId; - WriteVerbose(string.Format("No application id provided - created new AD application with application id '{0}'", ApplicationId)); - printPassword = true; - } - } - - CreatePSServicePrincipalParameters createParameters = new CreatePSServicePrincipalParameters - { - ApplicationId = ApplicationId, - AccountEnabled = true, - }; - - var shouldProcessMessage = string.Format("Adding a new service principal to be associated with an application " + - "having AppId '{0}' with no permissions.", createParameters.ApplicationId); - - if (!SkipRoleAssignment()) - { - if (!this.IsParameterBound(c => c.Scope)) - { - Scope = string.Format("/subscriptions/{0}", subscriptionId); - WriteVerbose(string.Format("No scope provided - using the default scope '{0}'", Scope)); - } - - AuthorizationClient.ValidateScope(Scope, true); - - if (!this.IsParameterBound(c => c.Role)) - { - Role = "Contributor"; - WriteVerbose(string.Format("No role provided - using the default role '{0}'", Role)); - } - - shouldProcessMessage = string.Format("Adding a new service principal to be associated with an application " + - "having AppId '{0}' with '{1}' role over scope '{2}'.", createParameters.ApplicationId, this.Role, this.Scope); - } - - if (ShouldProcess(target: createParameters.ApplicationId.ToString(), action: shouldProcessMessage)) - { - PSADServicePrincipalWrapper servicePrincipal = new PSADServicePrincipalWrapper(ActiveDirectoryClient.CreateServicePrincipal(createParameters)); - if(printPassword) - { - servicePrincipal.Secret = Password; - } - else if(printUseExistingSecret) - { - WriteVerbose(String.Format(ProjectResources.ServicePrincipalCreatedWithCredentials, ApplicationId)); - } - WriteObject(servicePrincipal); - if (SkipRoleAssignment()) - { - WriteVerbose("Skipping role assignment for the service principal."); - return; - } - - WriteWarning(string.Format("Assigning role '{0}' over scope '{1}' to the new service principal.", this.Role, this.Scope)); - FilterRoleAssignmentsOptions parameters = new FilterRoleAssignmentsOptions() - { - Scope = this.Scope, - RoleDefinitionName = this.Role, - ADObjectFilter = new ADObjectFilterOptions - { - SPN = servicePrincipal.ApplicationId.ToString(), - Id = servicePrincipal.Id.ToString() - }, - ResourceIdentifier = new ResourceIdentifier() - { - Subscription = subscriptionId - }, - CanDelegate = false - }; - - for (var i = 0; i < 6; i++) - { - try - { - TestMockSupport.Delay(5000); - PoliciesClient.CreateRoleAssignment(parameters); - var ra = PoliciesClient.FilterRoleAssignments(parameters, subscriptionId); - if (ra != null) - { - WriteVerbose(string.Format("Role assignment with role '{0}' and scope '{1}' successfully created for the created service principal.", this.Role, this.Scope)); - break; - } - } - catch (ErrorResponseException e) - { - throw new ErrorResponseException(string.Format(ProjectResources.ServicePrincipalRoleAssignmentCreationFailed,e.Body.Error.Message),e); - } - catch (Exception) - { - // if the error is something else fail silently as before - } - } - } - } - - private bool SkipRoleAssignment() - { - return this.IsParameterBound(c => c.SkipAssignment) || (!this.IsParameterBound(c => c.Role) && !this.IsParameterBound(c => c.Scope) && !HasSubscription()); - } - - private bool HasSubscription() - { - return DefaultContext.Subscription?.Id != null; - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADSpCredentialCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADSpCredentialCommand.cs deleted file mode 100644 index d11d2f083205..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADSpCredentialCommand.cs +++ /dev/null @@ -1,137 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Commands.Resources.Models.Authorization; -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Management.Automation; -using System.Security; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Creates a new AD servicePrincipal Credential. - /// - [CmdletOutputBreakingChange(typeof(PSADCredential), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphKeyCredential, Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphPasswordCredential")] - [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADSpCredential", DefaultParameterSetName = ParameterSet.SpObjectIdWithPassword, SupportsShouldProcess = true)] - [OutputType(typeof(PSADCredential), typeof(PSADCredentialWrapper))] - [Alias("New-" + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADServicePrincipalCredential")] - public class NewAzureADSpCredentialCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SpObjectIdWithCertValue, HelpMessage = "The servicePrincipal object id.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SpObjectIdWithPassword, HelpMessage = "The servicePrincipal object id.")] - [ValidateNotNullOrEmpty] - [Alias("ServicePrincipalObjectId")] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SPNWithCertValue, HelpMessage = "The servicePrincipal name.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SPNWithPassword, HelpMessage = "The servicePrincipal name.")] - [ValidateNotNullOrEmpty] - [Alias("SPN")] - public string ServicePrincipalName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ServicePrincipalObjectWithCertValue, HelpMessage = "The service principal object.")] - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ServicePrincipalObjectWithPassword, HelpMessage = "The service principal object.")] - [ValidateNotNullOrEmpty] - public PSADServicePrincipal ServicePrincipalObject { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SpObjectIdWithCertValue, - HelpMessage = "The base64 encoded value for the AsymmetricX509Cert associated with the servicePrincipal that will be valid for one year by default.")] - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SPNWithCertValue, - HelpMessage = "The base64 encoded value for the AsymmetricX509Cert associated with the servicePrincipal that will be valid for one year by default.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.ServicePrincipalObjectWithCertValue, - HelpMessage = "The base64 encoded value for the AsymmetricX509Cert associated with the servicePrincipal that will be valid for one year by default.")] - [ValidateNotNullOrEmpty] - public string CertValue { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The start date after which password or key would be valid. Default value is current time.")] - public DateTime StartDate { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "The end date till which password or key is valid. Default value is one year after the start date.")] - public DateTime EndDate { get; set; } - - public Guid KeyId { get; set; } = default(Guid); - - public NewAzureADSpCredentialCommand() - { - DateTime currentTime = DateTime.UtcNow; - StartDate = currentTime; - } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (!this.IsParameterBound(c => c.EndDate)) - { - WriteVerbose(Resources.Properties.Resources.DefaultEndDateUsed); - EndDate = StartDate.AddYears(1); - } - - if (this.IsParameterBound(c => c.ServicePrincipalObject)) - { - ObjectId = ServicePrincipalObject.Id; - } - - if (this.IsParameterBound(c => c.ServicePrincipalName)) - { - ObjectId = ActiveDirectoryClient.GetObjectIdFromSPN(ServicePrincipalName); - } - - if (this.IsParameterBound(c => c.CertValue)) - { - // Create object for key credential - var keyCredential = new KeyCredential() - { - EndDate = EndDate, - StartDate = StartDate, - KeyId = KeyId == default(Guid) ? Guid.NewGuid().ToString() : KeyId.ToString(), - Value = CertValue, - Type = "AsymmetricX509Cert", - Usage = "Verify" - }; - - if (ShouldProcess(target: ObjectId, action: string.Format("Adding a new caertificate to service principal with objectId {0}", ObjectId))) - { - WriteObject(ActiveDirectoryClient.CreateSpKeyCredential(ObjectId, keyCredential)); - } - } - else - { - // If no credentials provided, set the password to a randomly generated GUID - var Password = Guid.NewGuid().ToString().ConvertToSecureString(); - - string decodedPassword = SecureStringExtensions.ConvertToString(Password); - - var passwordCredential = new PasswordCredential() - { - EndDate = EndDate, - StartDate = StartDate, - KeyId = KeyId == default(Guid) ? Guid.NewGuid().ToString() : KeyId.ToString(), - Value = decodedPassword - }; - if (ShouldProcess(target: ObjectId, action: string.Format("Adding a new password to service principal with objectId {0}", ObjectId))) - { - var spCred = new PSADCredentialWrapper(ActiveDirectoryClient.CreateSpPasswordCredential(ObjectId, passwordCredential)); - spCred.Secret = Password; - WriteObject(spCred); - } - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADUserCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADUserCommand.cs deleted file mode 100644 index 6c23561623ae..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/NewAzureADUserCommand.cs +++ /dev/null @@ -1,85 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System.Management.Automation; -using System.Security; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Creates a new AD user. - /// - [CmdletOutputBreakingChange(typeof(PSADUser), ReplacementCmdletOutputTypeName = "Microsoft.Azure.PowerShell.Cmdlets.Resources.MSGraph.Models.ApiV10.IMicrosoftGraphUser")] - [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADUser", SupportsShouldProcess = true), OutputType(typeof(PSADUser))] - public class NewAzureADUserCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The display name for the user.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The userPrincipalName.")] - [ValidateNotNullOrEmpty] - public string UserPrincipalName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "Password for the user.")] - [ValidateNotNullOrEmpty] - [CmdletParameterBreakingChange("Password", ChangeDescription = "Parameter Password will not be supported, server generated secret text could be found in response")] - public SecureString Password { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "ImmutableId - to be specified only if you are using a federated domain for the user's user principal name (upn) property.")] - [ValidateNotNullOrEmpty] - public string ImmutableId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, HelpMessage = "The mail alias for the user.")] - public string MailNickname { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, HelpMessage = "It must be specified if the user should change the password on the next successful login. Default behavior is to not change the password on the next successful login.")] - public SwitchParameter ForceChangePasswordNextLogin { get; set; } - - - public override void ExecuteCmdlet() - { - string decodedPassword = SecureStringExtensions.ConvertToString(Password); - var userCreateparameters = new UserCreateParameters - { - AccountEnabled = true, - DisplayName = DisplayName, - MailNickname = MailNickname, - PasswordProfile = new PasswordProfile - { - Password = decodedPassword, - ForceChangePasswordNextLogin = ForceChangePasswordNextLogin.IsPresent ? true : false - }, - UserPrincipalName = UserPrincipalName - }; - - if (this.IsParameterBound(c => c.ImmutableId)) - { - userCreateparameters.ImmutableId = ImmutableId; - } - - ExecutionBlock(() => - { - if (ShouldProcess(target: UserPrincipalName, action: string.Format("Adding a new user with UPN '{0}'", UserPrincipalName))) - { - WriteObject(ActiveDirectoryClient.CreateUser(userCreateparameters)); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADAppCredentialCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADAppCredentialCommand.cs deleted file mode 100644 index bff7f5064791..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADAppCredentialCommand.cs +++ /dev/null @@ -1,99 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Management.Automation; -using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Removes AD application credentials. - /// - [Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADAppCredential", DefaultParameterSetName = ParameterSet.ApplicationObjectIdWithKeyId, SupportsShouldProcess = true), OutputType(typeof(bool))] - public class RemoveAzureADAppCredentialCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectIdWithKeyId, HelpMessage = "The application object id.")] - [ValidateNotNullOrEmpty] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdWithKeyId, HelpMessage = "The application id.")] - [ValidateNotNullOrEmpty] - public Guid ApplicationId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationDisplayName, HelpMessage = "The display name of the application.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectIdWithKeyId, HelpMessage = "The keyCredential Id.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdWithKeyId, HelpMessage = "The keyCredential Id.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.ApplicationObjectWithKeyId, HelpMessage = "The keyCredential Id.")] - [ValidateGuidNotEmpty] - public Guid KeyId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ApplicationObjectWithKeyId, HelpMessage = "The application object.")] - public PSADApplication ApplicationObject { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter PassThru { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter Force { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.ApplicationObject)) - { - ObjectId = ApplicationObject.ObjectId; - } - else if (this.IsParameterBound(c => c.ApplicationId)) - { - ObjectId = ActiveDirectoryClient.GetAppObjectIdFromApplicationId(ApplicationId); - } - else if (this.IsParameterBound(c => c.DisplayName)) - { - ObjectId = ActiveDirectoryClient.GetAppObjectIdFromDisplayName(DisplayName); - } - - if (this.IsParameterBound(c => c.KeyId)) - { - ConfirmAction( - Force.IsPresent, - string.Format(ProjectResources.RemovingAppCredentialWithId, KeyId, ObjectId), - ProjectResources.RemoveCredential, - ObjectId.ToString(), - () => ActiveDirectoryClient.RemoveAppCredentialByKeyId(ObjectId, KeyId)); - } - else - { - ConfirmAction( - Force.IsPresent, - string.Format(ProjectResources.RemovingAllAppCredentials, ObjectId.ToString()), - ProjectResources.RemoveCredential, - ObjectId.ToString(), - () => ActiveDirectoryClient.RemoveAllAppCredentials(ObjectId)); - } - - if (PassThru.IsPresent) - { - WriteObject(true); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADApplicationCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADApplicationCommand.cs deleted file mode 100644 index 5688fd3c017f..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADApplicationCommand.cs +++ /dev/null @@ -1,77 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Management.Automation; -using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Removes the AD application. - /// - [Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADApplication", DefaultParameterSetName = ParameterSet.ObjectId, SupportsShouldProcess = true), OutputType(typeof(bool))] - public class RemoveAzureADApplicationCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, HelpMessage = "The application object id.")] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationId, HelpMessage = "The application id.")] - public Guid ApplicationId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationDisplayName, HelpMessage = "The display name of the application.")] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.InputObject, HelpMessage = "The application object.")] - public PSADApplication InputObject { get; set;} - - [Parameter(Mandatory = false)] - public SwitchParameter PassThru { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter Force { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.InputObject)) - { - ObjectId = InputObject.ObjectId; - } - else if (this.IsParameterBound(c => c.ApplicationId)) - { - ObjectId = ActiveDirectoryClient.GetAppObjectIdFromApplicationId(ApplicationId); - } - else if (this.IsParameterBound(c => c.DisplayName)) - { - ObjectId = ActiveDirectoryClient.GetAppObjectIdFromDisplayName(DisplayName); - } - - ConfirmAction( - Force.IsPresent, - string.Format(ProjectResources.RemovingApplication, ObjectId), - ProjectResources.RemoveApplication, - ObjectId.ToString(), - () => ActiveDirectoryClient.RemoveApplication(ObjectId)); - - if (PassThru.IsPresent) - { - WriteObject(true); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADGroupCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADGroupCommand.cs deleted file mode 100644 index 7570925e33e1..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADGroupCommand.cs +++ /dev/null @@ -1,71 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System.Management.Automation; -using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; - - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - [Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADGroup", SupportsShouldProcess = true, DefaultParameterSetName = ParameterSet.DisplayName), OutputType(typeof(bool))] - public class RemoveAzureADGroupCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, HelpMessage = "The object id of the group to be removed.")] - [ValidateNotNullOrEmpty] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.DisplayName, HelpMessage = "The display name of the group to be removed.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.InputObject, HelpMessage = "The object representation of the group to be removed.")] - [ValidateNotNullOrEmpty] - public PSADGroup InputObject { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter PassThru { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter Force { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.InputObject)) - { - ObjectId = InputObject.Id; - } - else if (this.IsParameterBound(c => c.DisplayName)) - { - var group = ActiveDirectoryClient.GetGroupByDisplayName(DisplayName); - ObjectId = group.Id; - } - - ConfirmAction( - Force.IsPresent, - string.Format(ProjectResources.RemoveGroupConfirmation, ObjectId), - ProjectResources.RemovingGroup, - ObjectId.ToString(), - () => ActiveDirectoryClient.RemoveGroup(ObjectId.ToString())); - - if (PassThru.IsPresent) - { - WriteObject(true); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADGroupMemberCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADGroupMemberCommand.cs deleted file mode 100644 index be074b57a7d2..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADGroupMemberCommand.cs +++ /dev/null @@ -1,99 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Collections.Generic; -using System.Management.Automation; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Removes a user from a group. - /// - [Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADGroupMember", SupportsShouldProcess = true, DefaultParameterSetName = ParameterSet.Explicit), OutputType(typeof(bool))] - public class RemoveAzureADGroupMemberCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberObjectIdWithGroupDisplayName, HelpMessage = "The object id of the member(s) to remove.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberObjectIdWithGroupObject, HelpMessage = "The object id of the member(s) to remove.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberObjectIdWithGroupObjectId, HelpMessage = "The object id of the member(s) to remove.")] - [ValidateNotNullOrEmpty] - public string[] MemberObjectId { get; set; } - - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberUPNWithGroupDisplayName, HelpMessage = "The UPN of the member(s) to remove.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberUPNWithGroupObject, HelpMessage = "The UPN of the member(s) to remove.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberUPNWithGroupObjectId, HelpMessage = "The UPN of the member(s) to remove.")] - [ValidateNotNullOrEmpty] - public string[] MemberUserPrincipalName { get; set; } - - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberObjectIdWithGroupObjectId, HelpMessage = "The object id of the group to remove the member from.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberUPNWithGroupObjectId, HelpMessage = "The object id of the group to remove the member from.")] - [ValidateNotNullOrEmpty] - public string GroupObjectId { get; set; } - - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberObjectIdWithGroupDisplayName, HelpMessage = "The display name of the group to remove the member(s) from.")] - [Parameter(Mandatory = true, ParameterSetName = ParameterSet.MemberUPNWithGroupDisplayName, HelpMessage = "The display name of the group to remove the member(s) from.")] - [ValidateNotNullOrEmpty] - public string GroupDisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.MemberObjectIdWithGroupObject, HelpMessage = "The object representation of the group to remove the member from.")] - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.MemberUPNWithGroupObject, HelpMessage = "The object representation of the group to remove the member from.")] - [ValidateNotNullOrEmpty] - public PSADGroup GroupObject { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter PassThru { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.GroupObject)) - { - GroupObjectId = GroupObject.Id; - } - else if (this.IsParameterBound(c => c.GroupDisplayName)) - { - var group = ActiveDirectoryClient.GetGroupByDisplayName(GroupDisplayName); - GroupObjectId = group.Id; - - } - - if (this.IsParameterBound(c => c.MemberUserPrincipalName)) - { - var memberObjectId = new List(); - foreach (var memberUPN in MemberUserPrincipalName) - { - memberObjectId.Add(ActiveDirectoryClient.GetObjectIdFromUPN(memberUPN)); - } - - MemberObjectId = memberObjectId.ToArray(); - } - - foreach (var memberObjectId in MemberObjectId) - { - if (ShouldProcess(target: memberObjectId, action: string.Format("Removing user with object id '{0}' from group with object id '{1}'.", memberObjectId, GroupObjectId))) - { - ActiveDirectoryClient.RemoveGroupMember(GroupObjectId, memberObjectId); - } - } - - if (PassThru.IsPresent) - { - WriteObject(true); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADServicePrincipalCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADServicePrincipalCommand.cs deleted file mode 100644 index 7d9f91975236..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADServicePrincipalCommand.cs +++ /dev/null @@ -1,116 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Management.Automation; -using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Removes the service principal. - /// - [Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADServicePrincipal", SupportsShouldProcess = true, DefaultParameterSetName = ParameterSet.ObjectId),OutputType(typeof(PSADServicePrincipal))] - public class RemoveAzureADServicePrincipalCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, HelpMessage = "The service principal object id.")] - [ValidateNotNullOrEmpty] - [Alias("PrincipalId", "Id")] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationId, HelpMessage = "The service principal application id.")] - [ValidateNotNullOrEmpty] - public Guid ApplicationId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SPN, HelpMessage = "The service principal name.")] - [Alias("SPN")] - [ValidateNotNullOrEmpty] - public string ServicePrincipalName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayName, HelpMessage = "The display name of the service principal.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.InputObject, HelpMessage = "The service principal object.")] - [ValidateNotNullOrEmpty] - public PSADServicePrincipal InputObject { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ApplicationObject, HelpMessage = "The application object whose service principal is being removed.")] - [ValidateNotNullOrEmpty] - public PSADApplication ApplicationObject { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter PassThru { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter Force { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - PSADServicePrincipal servicePrincipal = null; - if (this.IsParameterBound(c => c.InputObject)) - { - ObjectId = InputObject.Id; - } - - if (!this.IsParameterBound(c => c.ObjectId)) - { - IEnumerable result = null; - if (this.IsParameterBound(c => c.ApplicationId) || this.IsParameterBound(c => c.ApplicationObject)) - { - var appId = ApplicationObject == null ? ApplicationId.ToString() : ApplicationObject.ApplicationId.ToString(); - Rest.Azure.OData.ODataQuery odataQuery = new Rest.Azure.OData.ODataQuery(s => s.AppId == appId); - result = ActiveDirectoryClient.FilterServicePrincipals(odataQuery); - } - else if (this.IsParameterBound(c => c.ServicePrincipalName) || this.IsParameterBound(c => c.DisplayName)) - { - ADObjectFilterOptions options = new ADObjectFilterOptions() - { - SPN = ServicePrincipalName, - SearchString = DisplayName - }; - - result = ActiveDirectoryClient.FilterServicePrincipals(options); - } - - if (result == null || !result.Any()) - { - throw new ArgumentException(string.Format("Could not find a service principal with the name {0}.", ServicePrincipalName)); - } - - ObjectId = result.Select(s => s.Id).FirstOrDefault(); - } - - - ConfirmAction( - Force.IsPresent, - string.Format(ProjectResources.RemovingServicePrincipal, ObjectId), - ProjectResources.RemoveServicePrincipal, - ObjectId, - () => servicePrincipal = ActiveDirectoryClient.RemoveServicePrincipal(ObjectId)); - - if (PassThru) - { - WriteObject(servicePrincipal); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADSpCredentialCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADSpCredentialCommand.cs deleted file mode 100644 index e140c9a6b9bd..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADSpCredentialCommand.cs +++ /dev/null @@ -1,101 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Management.Automation; -using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Removes AD SP credentials. - /// - [Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADSpCredential", DefaultParameterSetName = ParameterSet.ObjectIdWithKeyId, SupportsShouldProcess = true), OutputType(typeof(bool))] - [Alias("Remove-" + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADServicePrincipalCredential")] - public class RemoveAzureADSpCredentialCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectIdWithKeyId, HelpMessage = "The servicePrincipal object id.")] - [ValidateNotNullOrEmpty] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SPNWithKeyId, HelpMessage = "The servicePrincipal name.")] - [ValidateNotNullOrEmpty] - public string ServicePrincipalName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayNameWithKeyId, HelpMessage = "The display name of the service principal.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.ServicePrincipalObject, HelpMessage = "The service principal object.")] - [ValidateNotNullOrEmpty] - public PSADServicePrincipal ServicePrincipalObject { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectIdWithKeyId, HelpMessage = "The keyCredential Id.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SPNWithKeyId, HelpMessage = "The keyCredential Id.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ServicePrincipalObject, HelpMessage = "The keyCredential Id.")] - [ValidateGuidNotEmpty] - public Guid KeyId { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter PassThru { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter Force { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.ServicePrincipalObject)) - { - ObjectId = ServicePrincipalObject.Id; - } - else if (this.IsParameterBound(c => c.ServicePrincipalName)) - { - ObjectId = ActiveDirectoryClient.GetObjectIdFromSPN(ServicePrincipalName); - } - else if (this.IsParameterBound(c => c.DisplayName)) - { - ObjectId = ActiveDirectoryClient.GetObjectIdFromServicePrincipalDisplayName(DisplayName); - } - - if (this.IsParameterBound(c => c.KeyId)) - { - ConfirmAction( - Force.IsPresent, - string.Format(ProjectResources.RemovingSpCredentialWithId, KeyId, ObjectId), - ProjectResources.RemoveCredential, - ObjectId, - () => ActiveDirectoryClient.RemoveSpCredentialByKeyId(ObjectId, KeyId)); - } - else - { - ConfirmAction( - Force.IsPresent, - string.Format(ProjectResources.RemovingAllSpCredentials, ObjectId), - ProjectResources.RemoveCredential, - ObjectId, - () => ActiveDirectoryClient.RemoveAllSpCredentials(ObjectId)); - } - - if (PassThru.IsPresent) - { - WriteObject(true); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADUserCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADUserCommand.cs deleted file mode 100644 index 969f8500aab4..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/RemoveAzureADUserCommand.cs +++ /dev/null @@ -1,92 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Management.Automation; -using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Removes the AD user. - /// - [Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADUser", SupportsShouldProcess = true, DefaultParameterSetName = ParameterSet.UPNOrObjectId), OutputType(typeof(bool))] - public class RemoveAzureADUserCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.UPNOrObjectId, HelpMessage = "The userPrincipalName or ObjectId of the user to be deleted.")] - [ValidateNotNullOrEmpty] - public string UPNOrObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.UPN, HelpMessage = "The user principal name of the user to be deleted.")] - [ValidateNotNullOrEmpty] - [Alias("UPN")] - public string UserPrincipalName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, HelpMessage = "The object Id of the user to be deleted.")] - [ValidateNotNullOrEmpty] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.DisplayName, HelpMessage = "The display name of the user to be deleted.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.InputObject, HelpMessage = "The user object to be deleted.")] - [ValidateNotNullOrEmpty] - public PSADUser InputObject { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter PassThru { get; set; } - - [Parameter(Mandatory = false)] - public SwitchParameter Force { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.InputObject)) - { - UPNOrObjectId = !string.IsNullOrEmpty(InputObject.UserPrincipalName) ? - InputObject.UserPrincipalName : - InputObject.Id.ToString(); - } - else if (this.IsParameterBound(c => c.UserPrincipalName)) - { - UPNOrObjectId = UserPrincipalName; - } - else if (this.IsParameterBound(c => c.ObjectId)) - { - UPNOrObjectId = ObjectId; - } - else if (this.IsParameterBound(c => c.DisplayName)) - { - UPNOrObjectId = ActiveDirectoryClient.GetUserObjectIdFromDisplayName(DisplayName).ToString(); - } - - ConfirmAction( - Force.IsPresent, - string.Format(ProjectResources.RemoveUserConfirmation, UPNOrObjectId), - ProjectResources.RemovingUser, - UPNOrObjectId, - () => ActiveDirectoryClient.RemoveUser(UPNOrObjectId)); - - if (PassThru.IsPresent) - { - WriteObject(true); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/UpdateAzureADApplicationCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/UpdateAzureADApplicationCommand.cs deleted file mode 100644 index 596fceb4e64b..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/UpdateAzureADApplicationCommand.cs +++ /dev/null @@ -1,118 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Management.Automation; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Creates a new AD application. - /// - [CmdletOutputBreakingChange(typeof(PSADApplication), ReplacementCmdletOutputTypeName = "System.Boolean")] - [Cmdlet("Update", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADApplication", SupportsShouldProcess = true, DefaultParameterSetName = ParameterSet.ApplicationObjectIdWithUpdateParams), OutputType(typeof(PSADApplication))] - [Alias("Set-" + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADApplication")] - public class UpdateAzureADApplicationCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectIdWithUpdateParams, HelpMessage = "The application object id.")] - [ValidateNotNullOrEmpty] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdWithUpdateParams, HelpMessage = "The application id.")] - [ValidateNotNullOrEmpty] - public Guid ApplicationId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.InputObjectWithUpdateParams, HelpMessage = "The application object.")] - [ValidateNotNullOrEmpty] - public PSADApplication InputObject { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectIdWithUpdateParams, - HelpMessage = "The display name for the application.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdWithUpdateParams, - HelpMessage = "The display name for the application.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.InputObjectWithUpdateParams, - HelpMessage = "The display name for the application.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectIdWithUpdateParams, - HelpMessage = "The URL to the application's homepage.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdWithUpdateParams, - HelpMessage = "The URL to the application's homepage.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.InputObjectWithUpdateParams, - HelpMessage = "The URL to the application's homepage.")] - [ValidateNotNullOrEmpty] - public string HomePage { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectIdWithUpdateParams, - HelpMessage = "The URIs that identify the application.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdWithUpdateParams, - HelpMessage = "The URIs that identify the application.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.InputObjectWithUpdateParams, - HelpMessage = "The URIs that identify the application.")] - [ValidateNotNullOrEmpty] - [Alias("IdentifierUris")] - public string[] IdentifierUri { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectIdWithUpdateParams, - HelpMessage = "Specifies the URLs that user tokens are sent to for sign in, or the redirect URIs that OAuth 2.0 authorization codes and access tokens are sent to.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdWithUpdateParams, - HelpMessage = "Specifies the URLs that user tokens are sent to for sign in, or the redirect URIs that OAuth 2.0 authorization codes and access tokens are sent to.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.InputObjectWithUpdateParams, - HelpMessage = "Specifies the URLs that user tokens are sent to for sign in, or the redirect URIs that OAuth 2.0 authorization codes and access tokens are sent to.")] - [Alias("ReplyUrls")] - public string[] ReplyUrl { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationObjectIdWithUpdateParams, - HelpMessage = "True if the application is shared with other tenants; otherwise, false.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ApplicationIdWithUpdateParams, - HelpMessage = "True if the application is shared with other tenants; otherwise, false.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.InputObjectWithUpdateParams, - HelpMessage = "True if the application is shared with other tenants; otherwise, false.")] - public bool AvailableToOtherTenants { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.InputObject)) - { - ObjectId = InputObject.ObjectId; - } - else if (this.IsParameterBound(c => c.ApplicationId)) - { - ObjectId = ActiveDirectoryClient.GetAppObjectIdFromApplicationId(ApplicationId); - } - - ApplicationUpdateParameters parameters = new ApplicationUpdateParameters - { - DisplayName = DisplayName, - Homepage = HomePage, - IdentifierUris = IdentifierUri, - ReplyUrls = ReplyUrl, - AvailableToOtherTenants = this.IsParameterBound(c => c.AvailableToOtherTenants) ? AvailableToOtherTenants : (bool?)null - }; - - if (ShouldProcess(target: ObjectId, action: string.Format("Updating an application with object id '{0}'", ObjectId))) - { - ActiveDirectoryClient.UpdateApplication(ObjectId, parameters); - WriteObject(ActiveDirectoryClient.GetApplication(ObjectId)); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/UpdateAzureADServicePrincipalCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/UpdateAzureADServicePrincipalCommand.cs deleted file mode 100644 index f1e67adf2f97..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/UpdateAzureADServicePrincipalCommand.cs +++ /dev/null @@ -1,133 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Management.Automation; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Updates an existing service principal. - /// - [CmdletOutputBreakingChange(typeof(PSADServicePrincipal), ReplacementCmdletOutputTypeName = "System.Boolean")] - [Cmdlet(VerbsData.Update, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADServicePrincipal", DefaultParameterSetName = ParameterSet.SpObjectIdWithDisplayName, SupportsShouldProcess = true), OutputType(typeof(PSADServicePrincipal))] - [Alias("Set-" + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADServicePrincipal")] - - public class UpdateAzureADServicePrincipalCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SpObjectIdWithDisplayName, HelpMessage = "The servicePrincipal object id.")] - [ValidateNotNullOrEmpty] - [Alias("ServicePrincipalObjectId")] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SpApplicationIdWithDisplayName, HelpMessage = "The service principal application id.")] - [ValidateNotNullOrEmpty] - public Guid ApplicationId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SPNWithDisplayName, HelpMessage = "The servicePrincipal name.")] - [ValidateNotNullOrEmpty] - [Alias("SPN")] - public string ServicePrincipalName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.InputObjectWithDisplayName, HelpMessage = "The service principal object.")] - [ValidateNotNullOrEmpty] - public PSADServicePrincipal InputObject { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SpObjectIdWithDisplayName, HelpMessage = "The display name for the service principal.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.SPNWithDisplayName, HelpMessage = "The display name for the service principal.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.InputObjectWithDisplayName, HelpMessage = "The display name for the service principal.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = false, HelpMessage = "The homepage for the service principal.")] - public string Homepage { get; set; } - - [Parameter(Mandatory = false, HelpMessage = "The identifier URI(s) for the service principal.")] - public string[] IdentifierUri { get; set; } - - [Parameter(Mandatory = false, HelpMessage = "The key credential(s) for the service principal.")] - public KeyCredential[] KeyCredential { get; set; } - - [Parameter(Mandatory = false, HelpMessage = "The password credential(s) for the service principal.")] - public PasswordCredential[] PasswordCredential { get; set; } - - public override void ExecuteCmdlet() - { - ExecutionBlock(() => - { - var sp = InputObject; - if (sp == null) - { - IEnumerable result = null; - if (this.IsParameterBound(c => c.ApplicationId)) - { - var appId = ApplicationId.ToString(); - Rest.Azure.OData.ODataQuery odataQuery = new Rest.Azure.OData.ODataQuery(s => s.AppId == appId); - result = ActiveDirectoryClient.FilterServicePrincipals(odataQuery); - } - else - { - ADObjectFilterOptions options = new ADObjectFilterOptions() - { - SPN = ServicePrincipalName, - Id = ObjectId - }; - - result = ActiveDirectoryClient.FilterServicePrincipals(options); - } - - if (result == null) - { - throw new InvalidOperationException("ServicePrincipal does not exist."); - } - - sp = result.FirstOrDefault(); - } - - // Get AppObjectId - var applicationObjectId = GetObjectIdFromApplicationId(sp.ApplicationId.ToString()); - ApplicationUpdateParameters parameters = new ApplicationUpdateParameters() - { - DisplayName = DisplayName, - Homepage = Homepage, - IdentifierUris = (IdentifierUri == null) ? new string[] { } : IdentifierUri, - KeyCredentials = KeyCredential, - PasswordCredentials = PasswordCredential - }; - - if (ShouldProcess(target: sp.Id, action: string.Format("Updating properties on application associated with a service principal with object id '{0}'", sp.Id))) - { - ActiveDirectoryClient.UpdateApplication(applicationObjectId, parameters); - WriteObject(ActiveDirectoryClient.FilterServicePrincipals(new ADObjectFilterOptions() { Id = applicationObjectId }).FirstOrDefault()); - } - }); - } - - private string GetObjectIdFromApplicationId(string applicationId) - { - var odataQueryFilter = new Rest.Azure.OData.ODataQuery(a => a.AppId == applicationId); - var app = ActiveDirectoryClient.GetApplicationWithFilters(odataQueryFilter).SingleOrDefault(); - if (app == null) - { - throw new InvalidOperationException(String.Format("Application with AppId '{0}' does not exist.", applicationId)); - } - return app.ObjectId; - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Cmdlets/UpdateAzureADUserCommand.cs b/src/Resources/Resources/ActiveDirectory/Cmdlets/UpdateAzureADUserCommand.cs deleted file mode 100644 index 2e7b9853002e..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Cmdlets/UpdateAzureADUserCommand.cs +++ /dev/null @@ -1,121 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Graph.RBAC.Models; -using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; -using Microsoft.WindowsAzure.Commands.Utilities.Common; -using System; -using System.Management.Automation; -using System.Security; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - /// - /// Updates an existing AD user. - /// - [CmdletOutputBreakingChange(typeof(PSADUser), ReplacementCmdletOutputTypeName = "System.Boolean")] - [Cmdlet(VerbsData.Update, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADUser", SupportsShouldProcess = true, DefaultParameterSetName = ParameterSet.UPNOrObjectId), OutputType(typeof(PSADUser))] - [Alias("Set-" + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ADUser")] - public class UpdateAzureADUserCommand : ActiveDirectoryBaseCmdlet - { - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.UPNOrObjectId, HelpMessage = "The userPrincipalName or ObjectId of the user to be updated.")] - [ValidateNotNullOrEmpty] - public string UPNOrObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.UPN, HelpMessage = "The user principal name of the user to be updated.")] - [ValidateNotNullOrEmpty] - [Alias("UPN")] - public string UserPrincipalName { get; set; } - - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, HelpMessage = "The object Id of the user to be updated.")] - [ValidateNotNullOrEmpty] - public string ObjectId { get; set; } - - [Parameter(Mandatory = true, ValueFromPipeline = true, ParameterSetName = ParameterSet.InputObject, HelpMessage = "The object of the user to be updated.")] - [ValidateNotNullOrEmpty] - public PSADUser InputObject { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.UPNOrObjectId, HelpMessage = "New display name for the user.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.UPN, HelpMessage = "New display name for the user.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, HelpMessage = "New display name for the user.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.InputObject, HelpMessage = "New display name for the user.")] - [ValidateNotNullOrEmpty] - public string DisplayName { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.UPNOrObjectId, HelpMessage = "true for enabling the account; otherwise, false.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.UPN, HelpMessage = "true for enabling the account; otherwise, false.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, HelpMessage = "true for enabling the account; otherwise, false.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.InputObject, HelpMessage = "true for enabling the account; otherwise, false.")] - [ValidateNotNullOrEmpty] - public bool? EnableAccount { get; set; } - - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.UPNOrObjectId, HelpMessage = "New password for the user.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.UPN, HelpMessage = "New password for the user.")] - [Parameter(Mandatory = false, ValueFromPipelineByPropertyName = true, ParameterSetName = ParameterSet.ObjectId, HelpMessage = "New password for the user.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.InputObject, HelpMessage = "New password for the user.")] - [ValidateNotNullOrEmpty] - public SecureString Password { get; set; } - - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.UPNOrObjectId, HelpMessage = "It must be specified if the user should change the password on the next successful login. Only valid if password is updated otherwise it will be ignored.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.UPN, HelpMessage = "It must be specified if the user should change the password on the next successful login. Only valid if password is updated otherwise it will be ignored.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.ObjectId, HelpMessage = "It must be specified if the user should change the password on the next successful login. Only valid if password is updated otherwise it will be ignored.")] - [Parameter(Mandatory = false, ParameterSetName = ParameterSet.InputObject, HelpMessage = "It must be specified if the user should change the password on the next successful login. Only valid if password is updated otherwise it will be ignored.")] - public SwitchParameter ForceChangePasswordNextLogin { get; set; } - - public override void ExecuteCmdlet() - { - PasswordProfile profile = null; - if (Password != null && Password.Length > 0) - { - string decodedPassword = SecureStringExtensions.ConvertToString(Password); - profile = new PasswordProfile - { - Password = decodedPassword, - ForceChangePasswordNextLogin = ForceChangePasswordNextLogin.IsPresent ? true : false - }; - } - - var userUpdateParameters = new UserUpdateParameters - { - AccountEnabled = EnableAccount, - DisplayName = DisplayName, - PasswordProfile = profile - }; - - ExecutionBlock(() => - { - if (this.IsParameterBound(c => c.InputObject)) - { - UPNOrObjectId = !string.IsNullOrEmpty(InputObject.UserPrincipalName) ? - InputObject.UserPrincipalName : - InputObject.Id.ToString(); - } - else if (this.IsParameterBound(c => c.UserPrincipalName)) - { - UPNOrObjectId = UserPrincipalName; - } - else if (this.IsParameterBound(c => c.ObjectId)) - { - UPNOrObjectId = ObjectId; - } - - if (ShouldProcess(target: UPNOrObjectId, action: string.Format("Updating properties for user with upn or object id '{0}'", UPNOrObjectId))) - { - WriteObject(ActiveDirectoryClient.UpdateUser(UPNOrObjectId, userUpdateParameters)); - } - }); - } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Models/ActiveDirectoryClient.cs b/src/Resources/Resources/ActiveDirectory/Models/ActiveDirectoryClient.cs index e3b70758fb75..c1cadea3f024 100644 --- a/src/Resources/Resources/ActiveDirectory/Models/ActiveDirectoryClient.cs +++ b/src/Resources/Resources/ActiveDirectory/Models/ActiveDirectoryClient.cs @@ -14,22 +14,25 @@ using Microsoft.Azure.Commands.Common.Authentication; using Microsoft.Azure.Commands.Common.Authentication.Abstractions; -using Microsoft.Azure.Commands.ResourceManager.Common.Paging; -using Microsoft.Azure.Graph.RBAC; -using Microsoft.Azure.Graph.RBAC.Models; +using Microsoft.Azure.Commands.Common.MSGraph.Version1_0; +using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Applications; +using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Applications.Models; +using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.DirectoryObjects; +using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Groups; +using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Groups.Models; +using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Users; +using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Users.Models; using Microsoft.Rest.Azure; -using System; + using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Net; -using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; namespace Microsoft.Azure.Commands.ActiveDirectory { public class ActiveDirectoryClient { - public GraphRbacManagementClient GraphClient { get; private set; } + public IMicrosoftGraphClient GraphClient { get; private set; } /// /// Creates new ActiveDirectoryClient using WindowsAzureSubscription. @@ -37,11 +40,16 @@ public class ActiveDirectoryClient /// public ActiveDirectoryClient(IAzureContext context) { - GraphClient = AzureSession.Instance.ClientFactory.CreateArmClient( - context, AzureEnvironment.Endpoint.Graph); - GraphClient.TenantID = context.Tenant.Id.ToString(); + GraphClient = AzureSession.Instance.ClientFactory.CreateArmClient( + context, AzureEnvironment.ExtendedEndpoint.MicrosoftGraphUrl); + (GraphClient as MicrosoftGraphClient).TenantID = context.Tenant.Id; } + /// + /// Gets a single directory object (user, service principal or group) according to filter. + /// + /// + /// public PSADObject GetADObject(ADObjectFilterOptions options) { PSADObject result = null; @@ -74,49 +82,24 @@ private static string Normalize(string s) return string.IsNullOrEmpty(s) ? null : s; } - public PSADServicePrincipal GetServicePrincipalByObjectId(string objectId) - { - PSADServicePrincipal servicePrincipal = null; - try - { - servicePrincipal = GraphClient.ServicePrincipals.Get(objectId).ToPSADServicePrincipal(); - } - catch { /* The service principal does not exist, ignore the exception. */ } - - return servicePrincipal; - } - - public PSADServicePrincipal GetServicePrincipalBySPN(string spn) - { - PSADServicePrincipal servicePrincipal = null; - try - { - var odataQuery = new Rest.Azure.OData.ODataQuery(s => s.ServicePrincipalNames.Contains(spn)); - servicePrincipal = GraphClient.ServicePrincipals.List(odataQuery.ToString()).First().ToPSADServicePrincipal(); - } - catch { /* The service principal does not exist, ignore the exception. */ } - - return servicePrincipal; - } - - public IEnumerable FilterServicePrincipals(Rest.Azure.OData.ODataQuery odataQuery, ulong first = ulong.MaxValue, ulong skip = 0) + public IEnumerable FilterServicePrincipals(Rest.Azure.OData.ODataQuery odataQuery, int first = int.MaxValue, int skip = 0) { - return new GenericPageEnumerable( - delegate () - { - return GraphClient.ServicePrincipals.List(odataQuery); - }, GraphClient.ServicePrincipals.ListNext, first, skip).Select(s => s.ToPSADServicePrincipal()); + var response = GraphClient.ServicePrincipals.ListServicePrincipal( + consistencyLevel: "eventual", + filter: OdataHelper.GetFilterString(odataQuery) + ); + return response.Value.Select(s => s.ToPSADServicePrincipal()); } - public IEnumerable FilterServicePrincipals(ADObjectFilterOptions options, ulong first = ulong.MaxValue, ulong skip = 0) + public IEnumerable FilterServicePrincipals(ADObjectFilterOptions options, int first = int.MaxValue, int skip = 0) { List servicePrincipals = new List(); - ServicePrincipal servicePrincipal = null; + MicrosoftGraphServicePrincipal servicePrincipal = null; if (!string.IsNullOrEmpty(options.Id)) { try { - servicePrincipal = GraphClient.ServicePrincipals.Get(options.Id); + servicePrincipal = GraphClient.ServicePrincipals.GetServicePrincipal(options.Id); } catch { /* The user does not exist, ignore the exception. */ } @@ -129,8 +112,9 @@ public IEnumerable FilterServicePrincipals(ADObjectFilterO { try { - var odataQuery = new Rest.Azure.OData.ODataQuery(s => s.ServicePrincipalNames.Contains(options.SPN)); - servicePrincipal = GraphClient.ServicePrincipals.List(odataQuery.ToString()).FirstOrDefault(); + var odataQuery = new Rest.Azure.OData.ODataQuery(s => s.ServicePrincipalNames.Contains(options.SPN)); + // todo: doesn't support paging + servicePrincipal = GraphClient.ServicePrincipals.ListServicePrincipal(filter: OdataHelper.GetFilterString(odataQuery)).Value.FirstOrDefault(); } catch { /* The user does not exist, ignore the exception. */ } @@ -141,15 +125,15 @@ public IEnumerable FilterServicePrincipals(ADObjectFilterO } else { - Rest.Azure.OData.ODataQuery odataQuery = null; + Rest.Azure.OData.ODataQuery odataQuery = null; if (!string.IsNullOrEmpty(options.SearchString) && options.SearchString.EndsWith("*")) { options.SearchString = options.SearchString.TrimEnd('*'); - odataQuery = new Rest.Azure.OData.ODataQuery(s => s.DisplayName != null && s.DisplayName.StartsWith(options.SearchString)); + odataQuery = new Rest.Azure.OData.ODataQuery(s => s.DisplayName != null && s.DisplayName.StartsWith(options.SearchString)); } else { - odataQuery = new Rest.Azure.OData.ODataQuery(s => s.DisplayName == options.SearchString); + odataQuery = new Rest.Azure.OData.ODataQuery(s => s.DisplayName == options.SearchString); } return FilterServicePrincipals(odataQuery, first, skip); @@ -158,30 +142,14 @@ public IEnumerable FilterServicePrincipals(ADObjectFilterO return servicePrincipals; } - public PSADUser CreateUser(UserCreateParameters userCreateParam) - { - return GraphClient.Users.Create(userCreateParam).ToPSADUser(); - } - - public PSADUser UpdateUser(string upnOrObjectId, UserUpdateParameters userUpdateParam) - { - GraphClient.Users.Update(upnOrObjectId, userUpdateParam); - return GraphClient.Users.Get(upnOrObjectId).ToPSADUser(); - } - - public void RemoveUser(string upnOrObjectId) - { - GraphClient.Users.Delete(upnOrObjectId); - } - - public IEnumerable FilterUsers(ADObjectFilterOptions options, ulong first = ulong.MaxValue, ulong skip = 0) + public IEnumerable FilterUsers(ADObjectFilterOptions options, int first = int.MaxValue, int skip = 0) { if (!string.IsNullOrEmpty(options.Id)) { - User user = null; + MicrosoftGraphUser user = null; try { - user = GraphClient.Users.Get(Normalize(options.Id)); + user = GraphClient.Users.GetUser(Normalize(options.Id)); } catch { /* The user does not exist, ignore the exception. */ } @@ -192,11 +160,11 @@ public IEnumerable FilterUsers(ADObjectFilterOptions options, ulong fi } else if (!string.IsNullOrEmpty(options.UPN) || !string.IsNullOrEmpty(options.Mail)) { - IPage result = null; + IList result = null; try { string upnOrMail = Normalize(options.UPN) ?? Normalize(options.Mail); - var odataQuery = new Rest.Azure.OData.ODataQuery(); + var odataQuery = new Rest.Azure.OData.ODataQuery(); if (!string.IsNullOrEmpty(options.UPN)) { odataQuery.SetFilter(u => u.UserPrincipalName == upnOrMail); @@ -205,7 +173,10 @@ public IEnumerable FilterUsers(ADObjectFilterOptions options, ulong fi { odataQuery.SetFilter(u => u.Mail == upnOrMail); } - result = GraphClient.Users.List(odataQuery); + result = GraphClient.Users.ListUser( + "eventual", + filter: OdataHelper.GetFilterString(odataQuery) + ).Value; } catch { /* The user does not exist, ignore the exception. */ } @@ -216,69 +187,58 @@ public IEnumerable FilterUsers(ADObjectFilterOptions options, ulong fi } else { - Rest.Azure.OData.ODataQuery odataQuery = null; + Rest.Azure.OData.ODataQuery odataQuery = null; if (!string.IsNullOrEmpty(options.SearchString) && options.SearchString.EndsWith("*")) { options.SearchString = options.SearchString.TrimEnd('*'); - odataQuery = new Rest.Azure.OData.ODataQuery(u => u.DisplayName != null && u.DisplayName.StartsWith(options.SearchString)); + odataQuery = new Rest.Azure.OData.ODataQuery(u => u.DisplayName != null && u.DisplayName.StartsWith(options.SearchString)); } else { - odataQuery = new Rest.Azure.OData.ODataQuery(u => u.DisplayName == options.SearchString); + odataQuery = new Rest.Azure.OData.ODataQuery(u => u.DisplayName == options.SearchString); } - return new GenericPageEnumerable( - delegate () - { - return GraphClient.Users.List(odataQuery.ToString()); - }, GraphClient.Users.ListNext, first, skip).Select(u => u.ToPSADUser()); + return GraphClient.Users.ListUser( + consistencyLevel: "eventual", + filter: OdataHelper.GetFilterString(odataQuery) + ).Value.Select(u => u.ToPSADUser()); } return new List(); } - public IEnumerable FilterUsers() - { - return FilterUsers(new ADObjectFilterOptions()); - } - - public List ListUserGroups(string principal) - { - List result = new List(); - string objectId = GetObjectId(new ADObjectFilterOptions { UPN = principal }); - PSADObject user = GetADObject(new ADObjectFilterOptions { Id = objectId.ToString() }); - var groupsIds = GraphClient.Users.GetMemberGroups(objectId.ToString(), new UserGetMemberGroupsParameters()); - var groupsResult = GraphClient.Objects.GetObjectsByObjectIds(new GetObjectsParameters { ObjectIds = groupsIds.ToList() }); - result.AddRange(groupsResult.Select(g => g.ToPSADGroup())); - return result; - } - /// /// The graph getobjectsbyObjectId API supports 1000 objectIds per call. /// Due to this we are batching objectIds by chunk size of 1000 per APi call if it exceeds 1000 /// public List GetObjectsByObjectId(List objectIds) { + // todo: do we want to use 1000 as batch count in msgraph API? List result = new List(); - IPage adObjects; + IList adObjects; int objectIdBatchCount; - for (int i = 0; i < objectIds.Count; i += 1000) + const int batchCount = 1000; + for (int i = 0; i < objectIds.Count; i += batchCount) { - if ((i + 1000) > objectIds.Count) + if ((i + batchCount) > objectIds.Count) { objectIdBatchCount = objectIds.Count - i; } else { - objectIdBatchCount = 1000; + objectIdBatchCount = batchCount; } List objectIdBatch = objectIds.GetRange(i, objectIdBatchCount); try { - adObjects = GraphClient.Objects.GetObjectsByObjectIds(new GetObjectsParameters { ObjectIds = objectIdBatch, IncludeDirectoryObjectReferences = true }); + adObjects = GraphClient.DirectoryObjects.GetByIds( + new Common.MSGraph.Version1_0.DirectoryObjects.Models.Body() + { + Ids = objectIdBatch + }).Value; result.AddRange(adObjects.Select(o => o.ToPSADObject())); } - catch (CloudException ce) when (objectIds.Count == 1 && ce.Request.RequestUri.AbsolutePath.StartsWith("//")) + catch (Common.MSGraph.Version1_0.DirectoryObjects.Models.OdataErrorException oe) when (objectIds.Count == 1 && oe.Request.RequestUri.AbsolutePath.StartsWith("//")) { // absorb malformed string // this is a quirk from how strings are formed when requesting an RA from an SP @@ -290,23 +250,7 @@ public List GetObjectsByObjectId(List objectIds) return result; } - public PSADGroup GetGroupByDisplayName(string displayName) - { - var group = FilterGroups(new ADObjectFilterOptions() { SearchString = displayName }); - if (group.Count() > 1) - { - throw new InvalidOperationException(string.Format(ProjectResources.MultipleGroupsWithDisplayNameFound, displayName)); - } - - if (group.Count() == 0) - { - throw new InvalidOperationException(string.Format(ProjectResources.GroupWithDisplayNameDoesntExist, displayName)); - } - - return group.FirstOrDefault(); - } - - public IEnumerable FilterGroups(ADObjectFilterOptions options, ulong first = ulong.MaxValue, ulong skip = 0) + public IEnumerable FilterGroups(ADObjectFilterOptions options, int first = int.MaxValue, int skip = 0) { if (!string.IsNullOrEmpty(options.Id)) { @@ -325,68 +269,26 @@ public IEnumerable FilterGroups(ADObjectFilterOptions options, ulong } else if (options.Mail != null) { - Rest.Azure.OData.ODataQuery odataQuery = new Rest.Azure.OData.ODataQuery(g => g.Mail == options.Mail); - return new GenericPageEnumerable( - delegate () - { - return GraphClient.Groups.List(odataQuery); - }, GraphClient.Groups.ListNext, first, skip).Select(g => g.ToPSADGroup()); + Rest.Azure.OData.ODataQuery odataQuery = new Rest.Azure.OData.ODataQuery(g => g.Mail == options.Mail); + return GraphClient.Groups.ListGroup(filter: OdataHelper.GetFilterString(odataQuery)).Value.Select(g => g.ToPSADGroup()); } else { - Rest.Azure.OData.ODataQuery odataQuery = null; + Rest.Azure.OData.ODataQuery odataQuery = null; if (!string.IsNullOrEmpty(options.SearchString) && options.SearchString.EndsWith("*")) { options.SearchString = options.SearchString.TrimEnd('*'); - odataQuery = new Rest.Azure.OData.ODataQuery(g => g.DisplayName.StartsWith(options.SearchString)); + odataQuery = new Rest.Azure.OData.ODataQuery(g => g.DisplayName.StartsWith(options.SearchString)); } else { - odataQuery = new Rest.Azure.OData.ODataQuery(g => g.DisplayName == options.SearchString); + odataQuery = new Rest.Azure.OData.ODataQuery(g => g.DisplayName == options.SearchString); } - return new GenericPageEnumerable( - delegate () - { - return GraphClient.Groups.List(odataQuery); - }, GraphClient.Groups.ListNext, first, skip).Select(g => g.ToPSADGroup()); + return GraphClient.Groups.ListGroup(filter: OdataHelper.GetFilterString(odataQuery)).Value.Select(g => g.ToPSADGroup()); } } - public IEnumerable FilterGroups() - { - return FilterGroups(new ADObjectFilterOptions()); - } - - public PSADGroup CreateGroup(GroupCreateParameters groupCreateParams) - { - return GraphClient.Groups.Create(groupCreateParams).ToPSADGroup(); - } - - public void RemoveGroup(string groupObjectId) - { - GraphClient.Groups.Delete(groupObjectId); - } - - public IEnumerable GetGroupMembers(ADObjectFilterOptions options, ulong first = ulong.MaxValue, ulong skip = 0) - { - return new GenericPageEnumerable( - delegate () - { - return GraphClient.Groups.GetGroupMembers(options.Id); - }, GraphClient.Groups.GetGroupMembersNext, first, skip).Select(m => m.ToPSADObject()); - } - - public void AddGroupMember(string groupObjectId, GroupAddMemberParameters groupAddMemberParams) - { - GraphClient.Groups.AddMember(groupObjectId, groupAddMemberParams); - } - - public void RemoveGroupMember(string groupObjectId, string memberObjectId) - { - GraphClient.Groups.RemoveMember(groupObjectId, memberObjectId); - } - public string GetObjectId(ADObjectFilterOptions options) { if (options != null && options.Id != null) @@ -405,403 +307,5 @@ public string GetObjectId(ADObjectFilterOptions options) return adObj.Id; } } - - public void UpdateApplication(string appObjectId, ApplicationUpdateParameters parameters) - { - GraphClient.Applications.Patch(appObjectId, parameters); - } - - public PSADApplication CreateApplication(CreatePSApplicationParameters createParameters) - { - IList passwordCredentials = createParameters.PasswordCredentials != null - ? createParameters.PasswordCredentials.Select(psCredential => psCredential.ToGraphPasswordCredential()).ToList() - : null; - - IList keyCredentials = createParameters.KeyCredentials != null - ? createParameters.KeyCredentials.Select(psCredential => psCredential.ToGraphKeyCredential()).ToList() - : null; - - ApplicationCreateParameters graphParameters = new ApplicationCreateParameters - { - DisplayName = createParameters.DisplayName, - Homepage = createParameters.HomePage, - IdentifierUris = createParameters.IdentifierUris, - ReplyUrls = createParameters.ReplyUrls, - AvailableToOtherTenants = createParameters.AvailableToOtherTenants, - PasswordCredentials = passwordCredentials, - KeyCredentials = keyCredentials - }; - - try - { - return GraphClient.Applications.Create(graphParameters).ToPSADApplication(); - } - catch (GraphErrorException ce) - { - if (ce.Response.StatusCode == HttpStatusCode.Forbidden) - { - User currentUser = GraphClient.SignedInUser.Get(); - if (currentUser != null && string.Equals(currentUser.UserType, "Guest", StringComparison.InvariantCultureIgnoreCase)) - { - throw new InvalidOperationException(ProjectResources.CreateApplicationNotAllowedGuestUser); - } - } - - throw; - } - } - - private void ValidateKeyCredential(KeyCredential credential) - { - if (credential == null || string.IsNullOrEmpty(credential.KeyId) || string.IsNullOrEmpty(credential.Value) || - string.IsNullOrEmpty(credential.Type) || string.IsNullOrEmpty(credential.Usage) || credential.StartDate == null || credential.EndDate == null) - { - throw new InvalidOperationException(ProjectResources.KeyCredentialNotValid); - } - } - - private void ValidatePasswordCredential(PasswordCredential credential) - { - if (credential == null || string.IsNullOrEmpty(credential.KeyId) || string.IsNullOrEmpty(credential.Value) || - credential.StartDate == null || credential.EndDate == null) - { - throw new InvalidOperationException(ProjectResources.PasswordCredentialNotValid); - } - } - - private List GetAppKeyCredentials(string appObjectId) - { - return GraphClient.Applications.ListKeyCredentials(appObjectId).ToList(); - } - - private List GetAppPasswordCredentials(string appObjectId) - { - return GraphClient.Applications.ListPasswordCredentials(appObjectId).ToList(); - } - - private void PatchAppKeyCredentials(string appObjectId, List keyCredentails) - { - if (keyCredentails == null) - { - keyCredentails = new List(); - } - - GraphClient.Applications.UpdateKeyCredentials(appObjectId, new KeyCredentialsUpdateParameters(keyCredentails)); - } - - private void PatchAppPasswordCredentials(string appObjectId, List passwordCredentials) - { - if (passwordCredentials == null) - { - passwordCredentials = new List(); - } - - GraphClient.Applications.UpdatePasswordCredentials(appObjectId, new PasswordCredentialsUpdateParameters(passwordCredentials)); - } - - public PSADCredential CreateAppKeyCredential(string appObjectId, KeyCredential credential) - { - ValidateKeyCredential(credential); - var keyCredsList = GetAppKeyCredentials(appObjectId); - // Add new KeyCredential to existing KeyCredential list - keyCredsList.Add(credential); - PatchAppKeyCredentials(appObjectId, keyCredsList); - return credential.ToPSADCredential(); - } - - public PSADCredential CreateAppPasswordCredential(string appObjectId, PasswordCredential credential) - { - ValidatePasswordCredential(credential); - var passwordCredsList = GetAppPasswordCredentials(appObjectId); - // Add new PasswordCredential to existing KeyCredential list - passwordCredsList.Add(credential); - PatchAppPasswordCredentials(appObjectId, passwordCredsList); - return credential.ToPSADCredential(); - } - - public List GetAppCredentials(string appObjectId) - { - List CredentialList = new List(); - var keyCredsList = GetAppKeyCredentials(appObjectId); - CredentialList.AddRange(keyCredsList.Select(kc => kc.ToPSADCredential())); - var passwordCredsList = GetAppPasswordCredentials(appObjectId); - CredentialList.AddRange(passwordCredsList.Select(pc => pc.ToPSADCredential())); - return CredentialList; - } - - - public void RemoveAppCredentialByKeyId(string appObjectId, Guid keyId) - { - var keyCredsList = GetAppKeyCredentials(appObjectId); - var toBeDeletedKeyCred = keyCredsList.Find(kc => Guid.Parse(kc.KeyId) == keyId); - if (toBeDeletedKeyCred != null) - { - keyCredsList.Remove(toBeDeletedKeyCred); - PatchAppKeyCredentials(appObjectId, keyCredsList); - } - else - { - var passwordCredsList = GetAppPasswordCredentials(appObjectId); - var toBeDeletedPasswwordCred = passwordCredsList.Find(pc => Guid.Parse(pc.KeyId) == keyId); - if (toBeDeletedPasswwordCred != null) - { - passwordCredsList.Remove(toBeDeletedPasswwordCred); - PatchAppPasswordCredentials(appObjectId, passwordCredsList); - } - } - } - - public void RemoveAllAppCredentials(string appObjectId) - { - PatchAppKeyCredentials(appObjectId, keyCredentails: null); - PatchAppPasswordCredentials(appObjectId, passwordCredentials: null); - } - - public string GetAppObjectIdFromApplicationId(Guid applicationId) - { - var applicationIdString = applicationId.ToString(); - var odataQueryFilter = new Rest.Azure.OData.ODataQuery(a => a.AppId == applicationIdString); - var app = GetApplicationWithFilters(odataQueryFilter).SingleOrDefault(); - if (app == null) - { - throw new InvalidOperationException(string.Format(ProjectResources.ApplicationWithAppIdDoesntExist, applicationId)); - } - return app.ObjectId; - } - - public string GetAppObjectIdFromDisplayName(string displayName) - { - var odataQueryFilter = new Rest.Azure.OData.ODataQuery(a => a.DisplayName == displayName); - var app = GetApplicationWithFilters(odataQueryFilter); - if (app == null || app.FirstOrDefault() == null) - { - throw new InvalidOperationException(string.Format(ProjectResources.ApplicationWithDisplayNameDoesntExist, displayName)); - } - - if (app.Count() > 1) - { - throw new InvalidOperationException(string.Format(ProjectResources.MultipleApplicationsWithDisplayNameFound, displayName)); - } - - return app.FirstOrDefault().ObjectId; - } - - public string GetUserObjectIdFromDisplayName(string displayName) - { - var odataQueryFilter = new Rest.Azure.OData.ODataQuery(u => u.DisplayName == displayName); - var user = GraphClient.Users.List(odataQueryFilter.ToString()); - if (user == null || user.FirstOrDefault() == null) - { - throw new InvalidOperationException(string.Format(ProjectResources.UserWithDisplayNameDoesntExist, displayName)); - } - - if (user.Count() > 1) - { - throw new InvalidOperationException(string.Format(ProjectResources.MultipleUsersWithDisplayNameFound, displayName)); - } - - return user.FirstOrDefault().ObjectId; - } - - private List GetSpKeyCredentials(string spObjectId) - { - return GraphClient.ServicePrincipals.ListKeyCredentials(spObjectId).ToList(); - } - - private List GetSpPasswordCredentials(string spObjectId) - { - return GraphClient.ServicePrincipals.ListPasswordCredentials(spObjectId).ToList(); - } - - private void PatchSpKeyCredentials(string spObjectId, List keyCredentails) - { - if (keyCredentails == null) - { - keyCredentails = new List(); - } - - GraphClient.ServicePrincipals.UpdateKeyCredentials(spObjectId, new KeyCredentialsUpdateParameters(keyCredentails)); - } - - private void PatchSpPasswordCredentials(string spObjectId, List passwordCredentials) - { - if (passwordCredentials == null) - { - passwordCredentials = new List(); - } - - GraphClient.ServicePrincipals.UpdatePasswordCredentials(spObjectId, new PasswordCredentialsUpdateParameters(passwordCredentials)); - } - - - public PSADCredential CreateSpKeyCredential(string spObjectId, KeyCredential credential) - { - ValidateKeyCredential(credential); - var keyCredsList = GetSpKeyCredentials(spObjectId); - // Add new KeyCredential to existing KeyCredential list - keyCredsList.Add(credential); - PatchSpKeyCredentials(spObjectId, keyCredsList); - return credential.ToPSADCredential(); - } - - public PSADCredential CreateSpPasswordCredential(string spObjectId, PasswordCredential credential) - { - ValidatePasswordCredential(credential); - var passwordCredsList = GetSpPasswordCredentials(spObjectId); - // Add new PasswordCredential to existing KeyCredential list - passwordCredsList.Add(credential); - PatchSpPasswordCredentials(spObjectId, passwordCredsList); - return credential.ToPSADCredential(); - } - - public List GetSpCredentials(string spObjectId) - { - List CredentialList = new List(); - var keyCredsList = GetSpKeyCredentials(spObjectId); - CredentialList.AddRange(keyCredsList.Select(kc => kc.ToPSADCredential())); - var passwordCredsList = GetSpPasswordCredentials(spObjectId); - CredentialList.AddRange(passwordCredsList.Select(pc => pc.ToPSADCredential())); - return CredentialList; - } - - public void RemoveSpCredentialByKeyId(string spObjectId, Guid keyId) - { - var keyCredsList = GetSpKeyCredentials(spObjectId); - var toBeDeletedKeyCred = keyCredsList.Find(kc => Guid.Parse(kc.KeyId) == keyId); - if (toBeDeletedKeyCred != null) - { - keyCredsList.Remove(toBeDeletedKeyCred); - PatchSpKeyCredentials(spObjectId, keyCredsList); - } - else - { - var passwordCredsList = GetSpPasswordCredentials(spObjectId); - var toBeDeletedPasswwordCred = passwordCredsList.Find(pc => Guid.Parse(pc.KeyId) == keyId); - if (toBeDeletedPasswwordCred != null) - { - passwordCredsList.Remove(toBeDeletedPasswwordCred); - PatchSpPasswordCredentials(spObjectId, passwordCredsList); - } - } - } - - public void RemoveAllSpCredentials(string spObjectId) - { - PatchSpKeyCredentials(spObjectId, keyCredentails: null); - PatchSpPasswordCredentials(spObjectId, passwordCredentials: null); - } - - public string GetObjectIdFromUPN(string upn) - { - var odataQueryFilter = new Rest.Azure.OData.ODataQuery(s => s.UserPrincipalName == upn); - var user = GraphClient.Users.List(odataQueryFilter.ToString()).SingleOrDefault(); - if (user == null) - { - throw new InvalidOperationException(String.Format(ProjectResources.UserWithUPNDoesntExist, upn)); - } - - return user.ObjectId; - } - - public string GetObjectIdFromSPN(string spn) - { - var odataQueryFilter = new Rest.Azure.OData.ODataQuery(s => s.ServicePrincipalNames.Contains(spn)); - var sp = GraphClient.ServicePrincipals.List(odataQueryFilter.ToString()).SingleOrDefault(); - if (sp == null) - { - throw new InvalidOperationException(String.Format(ProjectResources.ServicePrincipalWithSPNDoesntExist, spn)); - } - - return sp.ObjectId; - } - - public string GetObjectIdFromServicePrincipalDisplayName(string displayName) - { - var odataQueryFilter = new Rest.Azure.OData.ODataQuery(s => s.DisplayName == displayName); - var sp = GraphClient.ServicePrincipals.List(odataQueryFilter.ToString()); - if (sp == null || sp.FirstOrDefault() == null) - { - throw new InvalidOperationException(string.Format(ProjectResources.ServicePrincipalWithDisplayNameDoesntExist, displayName)); - } - - if (sp.Count() > 1) - { - throw new InvalidOperationException(string.Format(ProjectResources.MultipleServicePrincipalsWithDisplayNameFound, displayName)); - } - - return sp.FirstOrDefault().ObjectId; - } - - public void RemoveApplication(string applicationObjectId) - { - GraphClient.Applications.Delete(applicationObjectId); - } - - public PSADApplication GetApplication(string applicationObjectId) - { - return GraphClient.Applications.Get(applicationObjectId).ToPSADApplication(); - } - - public IEnumerable GetApplicationWithFilters(Rest.Azure.OData.ODataQuery odataQueryFilter, ulong first = ulong.MaxValue, ulong skip = 0) - { - return new GenericPageEnumerable( - delegate () - { - return GraphClient.Applications.List(odataQueryFilter); - }, GraphClient.Applications.ListNext, first, skip).Select(a => a.ToPSADApplication()); - } - - public PSADServicePrincipal CreateServicePrincipal(CreatePSServicePrincipalParameters createParameters) - { - IList passwordCredentials = createParameters.PasswordCredentials != null - ? createParameters.PasswordCredentials.Select(psCredential => psCredential.ToGraphPasswordCredential()).ToList() - : null; - - IList keyCredentials = createParameters.KeyCredentials != null - ? createParameters.KeyCredentials.Select(psCredential => psCredential.ToGraphKeyCredential()).ToList() - : null; - - ServicePrincipalCreateParameters graphParameters = new ServicePrincipalCreateParameters - { - AppId = createParameters.ApplicationId.ToString(), - AccountEnabled = createParameters.AccountEnabled.ToString(), - KeyCredentials = keyCredentials, - PasswordCredentials = passwordCredentials - }; - - try - { - return GraphClient.ServicePrincipals.Create(graphParameters).ToPSADServicePrincipal(); - } - catch (GraphErrorException ce) - { - if (ce.Response.StatusCode == HttpStatusCode.Forbidden) - { - User currentUser = GraphClient.SignedInUser.Get(); - if (currentUser != null && string.Equals(currentUser.UserType, "Guest", StringComparison.InvariantCultureIgnoreCase)) - { - throw new InvalidOperationException(ProjectResources.CreateServicePrincipalNotAllowedGuestUser); - } - } - - throw; - } - } - - public PSADServicePrincipal RemoveServicePrincipal(string objectId) - { - var objectIdString = objectId.ToString(); - PSADServicePrincipal servicePrincipal = FilterServicePrincipals(new ADObjectFilterOptions() { Id = objectId }).FirstOrDefault(); - if (servicePrincipal != null) - { - GraphClient.ServicePrincipals.Delete(objectIdString); - } - else - { - throw new KeyNotFoundException(string.Format(ProjectResources.ServicePrincipalDoesntExist, objectId)); - } - - return servicePrincipal; - } } } \ No newline at end of file diff --git a/src/Resources/Resources/ActiveDirectory/Models/ActiveDirectoryClientExtensions.cs b/src/Resources/Resources/ActiveDirectory/Models/ActiveDirectoryClientExtensions.cs index 1fbe5ef86f8b..ffaa7cfbf451 100644 --- a/src/Resources/Resources/ActiveDirectory/Models/ActiveDirectoryClientExtensions.cs +++ b/src/Resources/Resources/ActiveDirectory/Models/ActiveDirectoryClientExtensions.cs @@ -12,228 +12,102 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Microsoft.Azure.Graph.RBAC.Models; +using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Applications.Models; +using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Groups.Models; +using Microsoft.Azure.Commands.Common.MSGraph.Version1_0.Users.Models; +using Newtonsoft.Json; using System; using System.Linq; -using System.Text; namespace Microsoft.Azure.Commands.ActiveDirectory { internal static class ActiveDirectoryClientExtensions { - public static PSADObject ToPSADObject(this User user) - { - return new PSADObject() - { - DisplayName = user.DisplayName, - Id = user.ObjectId - }; - } - - public static PSADObject ToPSADObject(this ADGroup group) - { - return new PSADObject() - { - DisplayName = group.DisplayName, - Id = group.ObjectId - }; - } - - public static PSADObject ToPSADObject(this DirectoryObject obj) + public static PSADObject ToPSADObject(this Common.MSGraph.Version1_0.DirectoryObjects.Models.MicrosoftGraphDirectoryObject obj) { if (obj == null) throw new ArgumentNullException(); - if(obj is User user) + if (obj.IsUser()) { - return new PSADUser() - { - DisplayName = user.DisplayName, - Id = user.ObjectId, - DeletionTimestamp = user.DeletionTimestamp, - UserPrincipalName = user.UserPrincipalName, - AccountEnabled = user.AccountEnabled, - GivenName = user.GivenName, - Mail = user.Mail, - MailNickname = user.MailNickname, - Surname = user.Surname, - UsageLocation = user.UsageLocation, - Type = "User" - }; + return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(obj)).ToPSADUser(); } - else if(obj is ADGroup group) + if (obj.IsServicePrincipal()) { - return new PSADGroup() - { - DisplayName = group.DisplayName, - Id = group.ObjectId, - Type = "Group", - DeletionTimestamp = group.DeletionTimestamp, - SecurityEnabled = group.SecurityEnabled, - MailEnabled = group.MailEnabled, - MailNickname = !string.IsNullOrEmpty(group.Mail) ? group.Mail : - !string.IsNullOrEmpty(group.MailNickname) ? group.MailNickname : - group.AdditionalProperties.ContainsKey("mailNickname") ? group.AdditionalProperties["mailNickname"]?.ToString() : null, - Description = group.AdditionalProperties.ContainsKey("description") ? group.AdditionalProperties["description"]?.ToString() : null - }; + return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(obj)).ToPSADServicePrincipal(); } - else if(obj is ServicePrincipal sp) + if (obj.IsGroup()) { - return new PSADServicePrincipal() - { - DisplayName = sp.DisplayName, - Id = sp.ObjectId, - Type = "ServicePrincipal", - ServicePrincipalNames = sp.ServicePrincipalNames.ToArray() - }; + return JsonConvert.DeserializeObject(JsonConvert.SerializeObject(obj)).ToPSADGroup(); } - else - { - return new PSADObject() - { - Id = obj.ObjectId, - DeletionTimestamp = obj.DeletionTimestamp - }; - } - } - public static PSADObject ToPSADGroup(this DirectoryObject obj) - { return new PSADObject() { - Id = obj.ObjectId + Id = obj.Id, + DeletionTimestamp = obj.DeletedDateTime }; } - public static PSADUser ToPSADUser(this User user) + public static bool IsUser(this Common.MSGraph.Version1_0.DirectoryObjects.Models.MicrosoftGraphDirectoryObject obj) + { + return string.Equals(obj.Odatatype, "#microsoft.graph.user", StringComparison.OrdinalIgnoreCase); + } + public static bool IsServicePrincipal(this Common.MSGraph.Version1_0.DirectoryObjects.Models.MicrosoftGraphDirectoryObject obj) + { + return string.Equals(obj.Odatatype, "#microsoft.graph.servicePrincipal", StringComparison.OrdinalIgnoreCase); + } + public static bool IsGroup(this Common.MSGraph.Version1_0.DirectoryObjects.Models.MicrosoftGraphDirectoryObject obj) + { + return string.Equals(obj.Odatatype, "#microsoft.graph.group", StringComparison.OrdinalIgnoreCase); + } + + public static PSADUser ToPSADUser(this MicrosoftGraphUser user) { return new PSADUser() { DisplayName = user.DisplayName, - Id = user.ObjectId, + Id = user.Id, + DeletionTimestamp = user.DeletedDateTime, UserPrincipalName = user.UserPrincipalName, - Type = user.UserType, + Type = user.UserType ?? "User", UsageLocation = user.UsageLocation, GivenName = user.GivenName, Surname = user.Surname, AccountEnabled = user.AccountEnabled, MailNickname = user.MailNickname, Mail = user.Mail, - ImmutableId = user.ImmutableId, + ImmutableId = user.OnPremisesImmutableId, AdditionalProperties = user.AdditionalProperties }; } - public static PSADGroup ToPSADGroup(this ADGroup group) + public static PSADGroup ToPSADGroup(this MicrosoftGraphGroup group) { return new PSADGroup() { DisplayName = group.DisplayName, - Id = group.ObjectId, - DeletionTimestamp = group.DeletionTimestamp, + Id = group.Id, + DeletionTimestamp = group.DeletedDateTime, + Type = "Group", SecurityEnabled = group.SecurityEnabled, - MailNickname = !string.IsNullOrEmpty(group.Mail) ? group.Mail : group.AdditionalProperties.ContainsKey("mailNickname") ? group.AdditionalProperties["mailNickname"]?.ToString() : null, + MailNickname = !string.IsNullOrEmpty(group.Mail) ? group.Mail : group.AdditionalProperties.ContainsKey("mailNickname") ? group.AdditionalProperties["mailNickname"]?.ToString() : null, Description = group.AdditionalProperties.ContainsKey("description") ? group.AdditionalProperties["description"]?.ToString() : null, MailEnabled = group.MailEnabled, AdditionalProperties = group.AdditionalProperties }; } - public static PSADServicePrincipal ToPSADServicePrincipal(this ServicePrincipal servicePrincipal) + public static PSADServicePrincipal ToPSADServicePrincipal(this MicrosoftGraphServicePrincipal servicePrincipal) { return new PSADServicePrincipal() { DisplayName = servicePrincipal.DisplayName, - Id = servicePrincipal.ObjectId, - DeletionTimestamp = servicePrincipal.DeletionTimestamp, + Id = servicePrincipal.Id, + DeletionTimestamp = servicePrincipal.DeletedDateTime, ApplicationId = Guid.Parse(servicePrincipal.AppId), Type = "ServicePrincipal", - ServicePrincipalNames = servicePrincipal.ServicePrincipalNames.ToArray() - }; - } - - public static PSADApplication ToPSADApplication(this Application application) - { - if (application != null) - { - return new PSADApplication() - { - ObjectId = application.ObjectId, - DisplayName = application.DisplayName, - DeletionTimestamp = application.DeletionTimestamp, - ApplicationId = Guid.Parse(application.AppId), - IdentifierUris = application.IdentifierUris, - HomePage = application.Homepage, - ReplyUrls = application.ReplyUrls, - AppPermissions = application.AppPermissions, - AvailableToOtherTenants = application.AvailableToOtherTenants ?? false - }; - } - else - { - return null; - } - } - - public static KeyCredential ToGraphKeyCredential(this PSADKeyCredential PSKeyCredential) - { - return new KeyCredential - { - StartDate = PSKeyCredential.StartDate, - EndDate = PSKeyCredential.EndDate, - KeyId = PSKeyCredential.KeyId.ToString(), - Value = PSKeyCredential.CertValue, - Type = "AsymmetricX509Cert", - Usage = "Verify" - }; - } - - public static PasswordCredential ToGraphPasswordCredential(this PSADPasswordCredential PSPasswordCredential) - { - return new PasswordCredential - { - StartDate = PSPasswordCredential.StartDate, - EndDate = PSPasswordCredential.EndDate, - KeyId = PSPasswordCredential.KeyId.ToString(), - Value = PSPasswordCredential.Password + ServicePrincipalNames = servicePrincipal.ServicePrincipalNames.ToArray(), + AdditionalProperties = servicePrincipal.AdditionalProperties }; } - - public static PSADCredential ToPSADCredential(this KeyCredential credential) - { - return new PSADCredential - { - KeyId = credential.KeyId, - StartDate = credential.StartDate == null ? string.Empty : credential.StartDate.ToString(), - EndDate = credential.EndDate == null ? string.Empty : credential.EndDate.ToString(), - Type = credential.Type, - Usage = credential.Usage, - CustomKeyIdentifier = credential.CustomKeyIdentifier - }; - } - - public static PSADCredential ToPSADCredential(this PasswordCredential credential) - { - PSADCredential ret = new PSADCredential - { - KeyId = credential.KeyId, - StartDate = credential.StartDate == null ? string.Empty : credential.StartDate.ToString(), - EndDate = credential.EndDate == null ? string.Empty : credential.EndDate.ToString(), - Type = "Password" - }; - - if(credential.CustomKeyIdentifier != null && credential.CustomKeyIdentifier.Length > 0) - { - try - { - ret.CustomKeyIdentifier = Encoding.UTF8.GetString(credential.CustomKeyIdentifier); - } - catch - { - // Ignore this property if service response cannot be converted to string - } - } - - return ret; - } } } diff --git a/src/Resources/Resources/ActiveDirectory/Models/CreatePSApplicationParameters.cs b/src/Resources/Resources/ActiveDirectory/Models/CreatePSApplicationParameters.cs deleted file mode 100644 index 97b04d39a702..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Models/CreatePSApplicationParameters.cs +++ /dev/null @@ -1,33 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - public class CreatePSApplicationParameters - { - public string DisplayName { get; set; } - - public string HomePage { get; set; } - - public string[] IdentifierUris { get; set; } - - public string[] ReplyUrls { get; set; } - - public bool AvailableToOtherTenants { get; set; } - - public PSADKeyCredential[] KeyCredentials { get; set; } - - public PSADPasswordCredential[] PasswordCredentials { get; set; } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Models/CreatePSServicePrincipalParameters.cs b/src/Resources/Resources/ActiveDirectory/Models/CreatePSServicePrincipalParameters.cs deleted file mode 100644 index 961ca8fc2a5c..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Models/CreatePSServicePrincipalParameters.cs +++ /dev/null @@ -1,29 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - public class CreatePSServicePrincipalParameters - { - public Guid ApplicationId { get; set; } - - public bool AccountEnabled { get; set; } - - public PSADKeyCredential[] KeyCredentials { get; set; } - - public PSADPasswordCredential[] PasswordCredentials { get; set; } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Models/PSADApplication.cs b/src/Resources/Resources/ActiveDirectory/Models/OdataHelper.cs similarity index 50% rename from src/Resources/Resources/ActiveDirectory/Models/PSADApplication.cs rename to src/Resources/Resources/ActiveDirectory/Models/OdataHelper.cs index 1d0f5f8d5a42..91420355c6f7 100644 --- a/src/Resources/Resources/ActiveDirectory/Models/PSADApplication.cs +++ b/src/Resources/Resources/ActiveDirectory/Models/OdataHelper.cs @@ -13,26 +13,30 @@ // ---------------------------------------------------------------------------------- using System; -using System.Collections.Generic; +using System.Net; +using System.Web; namespace Microsoft.Azure.Commands.ActiveDirectory { - public class PSADApplication : PSADObject + public static class OdataHelper { - public string ObjectId { get; set; } + public static string GetFilterString(Rest.Azure.OData.ODataQuery odataQuery) + { + return HttpUtility.UrlDecode(odataQuery.Filter); + } - public IList IdentifierUris { get; set; } + public static bool IsAuthorizationDeniedException(Common.MSGraph.Version1_0.DirectoryObjects.Models.OdataErrorException oe) + { + if (oe.Response != null && oe.Response.StatusCode == HttpStatusCode.Forbidden && + oe.Body.Error != null && oe.Body.Error.Code != null && string.Equals(oe.Body.Error.Code, AuthorizationDeniedException, StringComparison.OrdinalIgnoreCase)) + { + return true; + } - public string HomePage { get; set; } + return false; + } - public Guid ApplicationId { get; set; } + public const string AuthorizationDeniedException = "Authorization_RequestDenied"; - public bool AvailableToOtherTenants { get; set; } - - public IList AppPermissions { get; set; } - - public IList ReplyUrls { get; set; } - - public string ObjectType => "Application"; } } diff --git a/src/Resources/Resources/ActiveDirectory/Models/PSADCredential.cs b/src/Resources/Resources/ActiveDirectory/Models/PSADCredential.cs deleted file mode 100644 index 1a6e15d89381..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Models/PSADCredential.cs +++ /dev/null @@ -1,31 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - public class PSADCredential - { - public string StartDate { get; set; } - - public string EndDate { get; set; } - - public string KeyId { get; set; } - - public string Type { get; set; } - - public string Usage { get; set; } - - public string CustomKeyIdentifier { get; set; } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Models/PSADKeyCredential.cs b/src/Resources/Resources/ActiveDirectory/Models/PSADKeyCredential.cs deleted file mode 100644 index 108b32b265c0..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Models/PSADKeyCredential.cs +++ /dev/null @@ -1,29 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - public class PSADKeyCredential - { - public DateTime StartDate { get; set; } - - public DateTime EndDate { get; set; } - - public Guid KeyId { get; set; } - - public string CertValue { get; set; } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Models/PSADPasswordCredential.cs b/src/Resources/Resources/ActiveDirectory/Models/PSADPasswordCredential.cs deleted file mode 100644 index 1af4b220c26c..000000000000 --- a/src/Resources/Resources/ActiveDirectory/Models/PSADPasswordCredential.cs +++ /dev/null @@ -1,29 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using System; - -namespace Microsoft.Azure.Commands.ActiveDirectory -{ - public class PSADPasswordCredential - { - public DateTime StartDate { get; set; } - - public DateTime EndDate { get; set; } - - public Guid KeyId { get; set; } - - public string Password { get; set; } - } -} diff --git a/src/Resources/Resources/ActiveDirectory/Models/PSErrorHelperObject.cs b/src/Resources/Resources/ActiveDirectory/Models/PSErrorHelperObject.cs index f92e17a9d329..e46e2cec4d4b 100644 --- a/src/Resources/Resources/ActiveDirectory/Models/PSErrorHelperObject.cs +++ b/src/Resources/Resources/ActiveDirectory/Models/PSErrorHelperObject.cs @@ -18,6 +18,7 @@ public enum ErrorTypeEnum { GenericError = 0, MalformedQuery = 1, + AuthorizationRequestDenied = 2 } public class PSErrorHelperObject : PSADObject diff --git a/src/Resources/Resources/Az.Resources.psd1 b/src/Resources/Resources/Az.Resources.psd1 index 55d969bb4661..b2d881ec3dd9 100644 --- a/src/Resources/Resources/Az.Resources.psd1 +++ b/src/Resources/Resources/Az.Resources.psd1 @@ -65,7 +65,6 @@ RequiredAssemblies = 'Microsoft.Azure.Management.Authorization.dll', 'Microsoft.Extensions.DependencyInjection.Abstractions.dll', 'Microsoft.Extensions.Options.dll', 'Microsoft.Extensions.Primitives.dll', - 'Microsoft.Azure.Graph.RBAC.dll', 'System.Runtime.CompilerServices.Unsafe.dll', 'AutoMapper.dll' # Script files (.ps1) that are run in the caller's environment prior to importing this module. diff --git a/src/Resources/Resources/ChangeLog.md b/src/Resources/Resources/ChangeLog.md index 4ce73aa92298..84a2df51e398 100644 --- a/src/Resources/Resources/ChangeLog.md +++ b/src/Resources/Resources/ChangeLog.md @@ -19,6 +19,9 @@ --> ## Upcoming Release +* [Breaking change] Migrated from AAD Graph to Microsoft Graph +* [Breaking change] Changed the returned `Id` in PSDenyAssignment from GUID string to fully qualified ID +* Allowed parameter `Id` in `Get-AzDenyAssignment` to accept fully qualified ID * Added new cmdlet `Publish-AzBicepModule` for publishing Bicep modules ## Version 4.4.1 diff --git a/src/Resources/Resources/DenyAssignments/GetAzureDenyAssignmentCommand.cs b/src/Resources/Resources/DenyAssignments/GetAzureDenyAssignmentCommand.cs index 36349145ed15..ab854a6dd1b6 100644 --- a/src/Resources/Resources/DenyAssignments/GetAzureDenyAssignmentCommand.cs +++ b/src/Resources/Resources/DenyAssignments/GetAzureDenyAssignmentCommand.cs @@ -17,7 +17,7 @@ using Microsoft.Azure.Commands.Resources.Models; using Microsoft.Azure.Commands.Resources.Models.Authorization; using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; + using System; using System.Collections.Generic; using System.Management.Automation; @@ -27,7 +27,6 @@ namespace Microsoft.Azure.Commands.Resources /// /// Filters deny assignments /// - [GenericBreakingChange(BreakingChangeMSGraphMigration)] [Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "DenyAssignment", DefaultParameterSetName = ParameterSet.Empty), OutputType(typeof(PSDenyAssignment))] public class GetAzureDenyAssignmentCommand : ResourcesBaseCmdlet { @@ -140,9 +139,9 @@ public class GetAzureDenyAssignmentCommand : ResourcesBaseCmdlet [ScopeCompleter] public string Scope { get; set; } - [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = DenyAssignmentIdParameterSet, HelpMessage = "Deny assignment id.")] - [ValidateGuidNotEmpty] - public Guid Id { get; set; } + [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = DenyAssignmentIdParameterSet, HelpMessage = "Deny assignment fully qualified ID or GUID. When Id is provided as a GUID, will take current subscription as default scope.")] + [ValidateNotNullOrEmpty] + public string Id { get; set; } [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true, ParameterSetName = DenyAssignmentNameParameterSet, HelpMessage = "Name of the deny assignment.")] diff --git a/src/Resources/Resources/Models.Authorization/AuthorizationClient.cs b/src/Resources/Resources/Models.Authorization/AuthorizationClient.cs index 3a37a372b8c2..ecf0f16b5ca6 100644 --- a/src/Resources/Resources/Models.Authorization/AuthorizationClient.cs +++ b/src/Resources/Resources/Models.Authorization/AuthorizationClient.cs @@ -12,18 +12,18 @@ // limitations under the License. // ---------------------------------------------------------------------------------- -using Hyak.Common; using Microsoft.Azure.Commands.ActiveDirectory; using Microsoft.Azure.Commands.Common.Authentication; using Microsoft.Azure.Commands.Common.Authentication.Abstractions; using Microsoft.Azure.Management.Authorization; using Microsoft.Azure.Management.Authorization.Models; -using Microsoft.Rest.Azure; +using Microsoft.Rest.Azure.OData; + using System; using System.Collections.Generic; using System.Linq; -using System.Management.Automation; using System.Net; + using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; namespace Microsoft.Azure.Commands.Resources.Models.Authorization @@ -128,16 +128,23 @@ public IEnumerable FilterRoleDefinitionsByCustom(string scope, /// The created role assignment object public PSRoleAssignment CreateRoleAssignment(FilterRoleAssignmentsOptions parameters, Guid roleAssignmentId = default(Guid)) { - var asigneeID = ActiveDirectoryClient.GetObjectId(parameters.ADObjectFilter); + var assigneeID = ActiveDirectoryClient.GetObjectId(parameters.ADObjectFilter); - string asigneeObjectType = parameters.ADObjectFilter?.ObjectType; - if (string.IsNullOrWhiteSpace(asigneeObjectType)) + string assigneeObjectType = parameters.ADObjectFilter?.ObjectType; + if (string.IsNullOrWhiteSpace(assigneeObjectType)) { - var asigneeObject = ActiveDirectoryClient.GetObjectsByObjectId(new List() { asigneeID }).SingleOrDefault(); - asigneeObjectType = (!(asigneeObject is PSErrorHelperObject) && asigneeObject != null) ? asigneeObject.Type : null; + try + { + var assigneeObject = ActiveDirectoryClient.GetObjectsByObjectId(new List() { assigneeID }).SingleOrDefault(); + assigneeObjectType = (!(assigneeObject is PSErrorHelperObject) && assigneeObject != null) ? assigneeObject.Type : null; + } + catch (Common.MSGraph.Version1_0.DirectoryObjects.Models.OdataErrorException oe) when (OdataHelper.IsAuthorizationDeniedException(oe)) + { + // Swallow the error from "Insufficient privileges to retrieve object by object id" + } } - string principalId = asigneeID; + string principalId = assigneeID; roleAssignmentId = roleAssignmentId == default(Guid) ? Guid.NewGuid() : roleAssignmentId; string scope = parameters.Scope; string roleDefinitionId = string.IsNullOrEmpty(parameters.RoleDefinitionName) @@ -149,7 +156,7 @@ public IEnumerable FilterRoleDefinitionsByCustom(string scope, var createParameters = new RoleAssignmentCreateParameters { PrincipalId = principalId.ToString(), - PrincipalType = asigneeObjectType, + PrincipalType = assigneeObjectType, RoleDefinitionId = roleDefinitionId, Description = parameters.Description, Condition = parameters.Condition, @@ -509,19 +516,20 @@ public List FilterDenyAssignments(FilterDenyAssignmentsOptions PSADObject adObject = null; Rest.Azure.OData.ODataQuery odataQuery = null; - if (options.DenyAssignmentId != Guid.Empty) + if (!string.IsNullOrEmpty(options.DenyAssignmentId) && + (Guid.Empty != options.DenyAssignmentId.GetGuidFromId())) { - var scope = !string.IsNullOrEmpty(options.Scope) ? options.Scope : AuthorizationHelper.GetSubscriptionScope(currentSubscription); + var scope = !string.IsNullOrEmpty(options.Scope) ? options.Scope : AuthorizationHelper.GetScopeFromFullyQualifiedId(options.DenyAssignmentId) ?? AuthorizationHelper.GetSubscriptionScope(currentSubscription); return new List { - AuthorizationManagementClient.DenyAssignments.Get(scope, options.DenyAssignmentId.ToString()) + AuthorizationManagementClient.DenyAssignments.Get(scope, options.DenyAssignmentId.GuidFromFullyQualifiedId()) .ToPSDenyAssignment(ActiveDirectoryClient, options.ExcludeAssignmentsForDeletedPrincipals) }; } if (!string.IsNullOrEmpty(options.DenyAssignmentName)) { - odataQuery = new Rest.Azure.OData.ODataQuery(item => item.DenyAssignmentName == options.DenyAssignmentName); + odataQuery = new ODataQuery(item => item.DenyAssignmentName == options.DenyAssignmentName); } else if (options.ADObjectFilter.HasFilter) { diff --git a/src/Resources/Resources/Models.Authorization/AuthorizationClientExtensions.cs b/src/Resources/Resources/Models.Authorization/AuthorizationClientExtensions.cs index afae1f17a988..69288c9f0f6b 100644 --- a/src/Resources/Resources/Models.Authorization/AuthorizationClientExtensions.cs +++ b/src/Resources/Resources/Models.Authorization/AuthorizationClientExtensions.cs @@ -29,7 +29,6 @@ internal static class AuthorizationClientExtensions private const string AllPrincipals = "All Principals"; private const string SystemDefined = "SystemDefined"; public const string CustomRole = "CustomRole"; - public const string AuthorizationDeniedException = "Authorization_RequestDenied"; public const string DeletedObject = "Unknown"; public static IEnumerable FilterRoleAssignmentsOnRoleId(this IEnumerable assignments, string roleId) @@ -135,7 +134,7 @@ public static IEnumerable ToPSDenyAssignments(this IEnumerable { adObjects = activeDirectoryClient.GetObjectsByObjectId(objectIds); } - catch (CloudException ce) when (IsAuthorizationDeniedException(ce)) + catch (Common.MSGraph.Version1_0.DirectoryObjects.Models.OdataErrorException oe) when (OdataHelper.IsAuthorizationDeniedException(oe)) { throw new InvalidOperationException(ProjectResources.InSufficientGraphPermission); } @@ -144,7 +143,7 @@ public static IEnumerable ToPSDenyAssignments(this IEnumerable { var psda = new PSDenyAssignment() { - Id = da.Id.GuidFromFullyQualifiedId(), + Id = da.Id, DenyAssignmentName = da.DenyAssignmentName, Description = da.Description, Actions = new List(da.Permissions.SelectMany(p => p.Actions)), @@ -177,14 +176,14 @@ public static PSDenyAssignment ToPSDenyAssignment(this DenyAssignment assignment { adObjects = activeDirectoryClient.GetObjectsByObjectId(objectIds); } - catch (CloudException ce) when (IsAuthorizationDeniedException(ce)) + catch (Common.MSGraph.Version1_0.DirectoryObjects.Models.OdataErrorException oe) when (OdataHelper.IsAuthorizationDeniedException(oe)) { throw new InvalidOperationException(ProjectResources.InSufficientGraphPermission); } var psda = new PSDenyAssignment() { - Id = assignment.Id.GuidFromFullyQualifiedId(), + Id = assignment.Id, DenyAssignmentName = assignment.DenyAssignmentName, Description = assignment.Description, Actions = new List(assignment.Permissions.SelectMany(p => p.Actions)), @@ -245,7 +244,7 @@ private static IEnumerable ToPSRoleAssignments(this IEnumerabl { adObjects = activeDirectoryClient.GetObjectsByObjectId(objectIds); } - catch (CloudException ce) when (IsAuthorizationDeniedException(ce)) + catch (Common.MSGraph.Version1_0.DirectoryObjects.Models.OdataErrorException oe) when (OdataHelper.IsAuthorizationDeniedException(oe)) { throw new InvalidOperationException(ProjectResources.InSufficientGraphPermission); } @@ -256,18 +255,18 @@ private static IEnumerable ToPSRoleAssignments(this IEnumerabl new PSADObject() { Id = assignment.PrincipalId }; PSRoleDefinition roleDefinition = roleDefinitions.SingleOrDefault(r => r.Id == assignment.RoleDefinitionId) ?? new PSRoleDefinition() { Id = assignment.RoleDefinitionId }; - if (adObject is PSADUser) + if (adObject is PSADUser user) { psAssignments.Add(new PSRoleAssignment() { RoleAssignmentId = assignment.Id, - DisplayName = adObject.DisplayName, + DisplayName = user.DisplayName, RoleDefinitionId = roleDefinition.Id, RoleDefinitionName = roleDefinition.Name, Scope = assignment.Scope, - SignInName = ((PSADUser)adObject).UserPrincipalName, - ObjectId = adObject.Id, - ObjectType = adObject.Type, + SignInName = user.UserPrincipalName, + ObjectId = user.Id, + ObjectType = user.Type, Description = assignment.Description, Condition = assignment.Condition, ConditionVersion = assignment.ConditionVersion, @@ -305,7 +304,7 @@ private static IEnumerable ToPSRoleAssignments(this IEnumerabl ConditionVersion = assignment.ConditionVersion, }); } - else if (adObject is PSErrorHelperObject && ((PSErrorHelperObject)adObject).ErrorType == ErrorTypeEnum.MalformedQuery) + else if (adObject is PSErrorHelperObject errorHelperObject && errorHelperObject.ErrorType == ErrorTypeEnum.MalformedQuery) { // swallow the previously handled error psAssignments.Add(new PSRoleAssignment() @@ -314,7 +313,6 @@ private static IEnumerable ToPSRoleAssignments(this IEnumerabl RoleDefinitionId = roleDefinition.Id, RoleDefinitionName = roleDefinition.Name, Scope = assignment.Scope, - ObjectType = assignment.Type, Description = assignment.Description, Condition = assignment.Condition, ConditionVersion = assignment.ConditionVersion, @@ -351,24 +349,8 @@ public static PSRoleAssignment ToPSRoleAssignment(this ClassicAdministrator clas DisplayName = classicAdministrator.EmailAddress, SignInName = classicAdministrator.EmailAddress, Scope = AuthorizationHelper.GetSubscriptionScope(currentSubscriptionId), - ObjectType = "User" + ObjectType = classicAdministrator.Type ?? "User" }; } - - private static string GuidFromFullyQualifiedId(this string Id) - { - return Id.TrimEnd('/').Substring(Id.LastIndexOf('/') + 1); - } - - private static bool IsAuthorizationDeniedException(CloudException ce) - { - if (ce.Response != null && ce.Response.StatusCode == HttpStatusCode.Unauthorized && - ce.Error != null && ce.Error.Code != null && string.Equals(ce.Error.Code, AuthorizationDeniedException, StringComparison.OrdinalIgnoreCase)) - { - return true; - } - - return false; - } } } diff --git a/src/Resources/Resources/Models.Authorization/AuthorizationHelper.cs b/src/Resources/Resources/Models.Authorization/AuthorizationHelper.cs index f668e75e3763..d4fab3325dd7 100644 --- a/src/Resources/Resources/Models.Authorization/AuthorizationHelper.cs +++ b/src/Resources/Resources/Models.Authorization/AuthorizationHelper.cs @@ -12,13 +12,16 @@ // limitations under the License. // ---------------------------------------------------------------------------------- +using System; using System.Text.RegularExpressions; namespace Microsoft.Azure.Commands.Resources.Models.Authorization { - public class AuthorizationHelper + public static class AuthorizationHelper { private static Regex subscriptionRegex = new Regex("/subscriptions/([^/]+)", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static Regex scopeRegex = new Regex("^(?:(?!/providers/).)*", RegexOptions.Compiled | RegexOptions.IgnoreCase); + public static string ConstructFullyQualifiedRoleDefinitionIdFromScopeAndIdAsGuid(string scope, string Id) { @@ -50,6 +53,22 @@ public static string GetSubscriptionScope(string subscriptionId) return string.Concat("/subscriptions/", subscriptionId); } + public static string GetScopeFromFullyQualifiedId(string fullyQualifiedId) + { + if (string.IsNullOrEmpty(fullyQualifiedId)) + { + return null; + } + var match = scopeRegex.Match(fullyQualifiedId); + + if (match.Success != true) + { + return null; + } + + return match.Groups[0].Value; + } + public static string GetResourceSubscription(string id) { var match = subscriptionRegex.Match(id); @@ -61,5 +80,20 @@ public static string GetResourceSubscription(string id) return match.Groups[1].Value; } + + public static string GuidFromFullyQualifiedId(this string Id) + { + return Id.TrimEnd('/').Substring(Id.LastIndexOf('/') + 1); + } + + public static Guid GetGuidFromId(this string Id) + { + if(Guid.TryParse(Id, out Guid result)) + { + return result; + } + + return new Guid(Id.GuidFromFullyQualifiedId()); + } } } diff --git a/src/Resources/Resources/Models.Authorization/FilterDenyAssignmentsOptions.cs b/src/Resources/Resources/Models.Authorization/FilterDenyAssignmentsOptions.cs index 2bfb5052b05e..a0cf54355f42 100644 --- a/src/Resources/Resources/Models.Authorization/FilterDenyAssignmentsOptions.cs +++ b/src/Resources/Resources/Models.Authorization/FilterDenyAssignmentsOptions.cs @@ -19,7 +19,7 @@ namespace Microsoft.Azure.Commands.Resources.Models.Authorization { public class FilterDenyAssignmentsOptions { - public Guid DenyAssignmentId { get; set; } + public string DenyAssignmentId { get; set; } public string DenyAssignmentName { get; set; } diff --git a/src/Resources/Resources/Models.Authorization/PSADCredentialWrapper.cs b/src/Resources/Resources/Models.Authorization/PSADCredentialWrapper.cs deleted file mode 100644 index 12110353e10a..000000000000 --- a/src/Resources/Resources/Models.Authorization/PSADCredentialWrapper.cs +++ /dev/null @@ -1,35 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Commands.ActiveDirectory; -using System.Security; - -namespace Microsoft.Azure.Commands.Resources.Models.Authorization -{ - public class PSADCredentialWrapper : PSADCredential - { - public PSADCredentialWrapper(PSADCredential cred) - { - if (cred != null) - { - StartDate = cred.StartDate; - EndDate = cred.EndDate; - KeyId = cred.KeyId; - Type = cred.Type; - } - } - - public SecureString Secret { get; set; } - } -} diff --git a/src/Resources/Resources/Models.Authorization/PSADServicePrincipalWrapper.cs b/src/Resources/Resources/Models.Authorization/PSADServicePrincipalWrapper.cs deleted file mode 100644 index 06d4645819a3..000000000000 --- a/src/Resources/Resources/Models.Authorization/PSADServicePrincipalWrapper.cs +++ /dev/null @@ -1,35 +0,0 @@ -// ---------------------------------------------------------------------------------- -// -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- - -using Microsoft.Azure.Commands.ActiveDirectory; -using System.Security; - -namespace Microsoft.Azure.Commands.Resources.Models.Authorization -{ - public class PSADServicePrincipalWrapper : PSADServicePrincipal - { - public PSADServicePrincipalWrapper(PSADServicePrincipal sp) - { - if (sp != null) - { - ApplicationId = sp.ApplicationId; - DisplayName = sp.DisplayName; - Id = sp.Id; - ServicePrincipalNames = sp.ServicePrincipalNames; - Type = sp.Type; - } - } - public SecureString Secret { get; set; } - } -} diff --git a/src/Resources/Resources/Models.ResourceGroups/ResourcesBaseCmdlet.cs b/src/Resources/Resources/Models.ResourceGroups/ResourcesBaseCmdlet.cs index cd5b229a67ae..1b1c5417d328 100644 --- a/src/Resources/Resources/Models.ResourceGroups/ResourcesBaseCmdlet.cs +++ b/src/Resources/Resources/Models.ResourceGroups/ResourcesBaseCmdlet.cs @@ -23,9 +23,6 @@ namespace Microsoft.Azure.Commands.Resources.Models /// public abstract class ResourcesBaseCmdlet : AzureRMCmdlet { - protected const string BreakingChangeMSGraphMigration = @"This cmdlet will use Microsoft Graph in Az 7.x and later. -Visit https://go.microsoft.com/fwlink/?linkid=2174792 for migration guide and breaking changes."; - /// /// Field that holds the resource client instance /// diff --git a/src/Resources/Resources/Properties/Resources.Designer.cs b/src/Resources/Resources/Properties/Resources.Designer.cs index 0e447728ea53..c8eae141c417 100644 --- a/src/Resources/Resources/Properties/Resources.Designer.cs +++ b/src/Resources/Resources/Properties/Resources.Designer.cs @@ -268,7 +268,7 @@ internal static string IncludeClassicAdminsNotSupported { } /// - /// Looks up a localized string similar to The User/Application doesn't have sufficient AAD graph permissions to perform the operation.. + /// Looks up a localized string similar to The User/Application doesn't have sufficient Microsoft Graph permissions to perform the operation.. /// internal static string InSufficientGraphPermission { get { diff --git a/src/Resources/Resources/Properties/Resources.resx b/src/Resources/Resources/Properties/Resources.resx index 0da575ce479d..5cde27fd607b 100644 --- a/src/Resources/Resources/Properties/Resources.resx +++ b/src/Resources/Resources/Properties/Resources.resx @@ -406,7 +406,7 @@ Service principal with SPN '{0}' does not exist. - The User/Application doesn't have sufficient AAD graph permissions to perform the operation. + The User/Application doesn't have sufficient Microsoft Graph permissions to perform the operation. Are you sure you want to remove group with object id '{0}'? diff --git a/src/Resources/Resources/Resources.csproj b/src/Resources/Resources/Resources.csproj index 2c8a9bf7f4a9..410715914faa 100644 --- a/src/Resources/Resources/Resources.csproj +++ b/src/Resources/Resources/Resources.csproj @@ -11,7 +11,6 @@ - diff --git a/src/Resources/Resources/RoleAssignments/GetAzureRoleAssignmentCommand.cs b/src/Resources/Resources/RoleAssignments/GetAzureRoleAssignmentCommand.cs index 2e8146971833..b938f8bb7b1c 100644 --- a/src/Resources/Resources/RoleAssignments/GetAzureRoleAssignmentCommand.cs +++ b/src/Resources/Resources/RoleAssignments/GetAzureRoleAssignmentCommand.cs @@ -17,7 +17,7 @@ using Microsoft.Azure.Commands.Resources.Models; using Microsoft.Azure.Commands.Resources.Models.Authorization; using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; + using System; using System.Collections.Generic; using System.Management.Automation; @@ -27,7 +27,6 @@ namespace Microsoft.Azure.Commands.Resources /// /// Filters role assignments /// - [GenericBreakingChange(BreakingChangeMSGraphMigration)] [Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoleAssignment", DefaultParameterSetName = ParameterSet.Empty), OutputType(typeof(PSRoleAssignment))] public class GetAzureRoleAssignmentCommand : ResourcesBaseCmdlet { diff --git a/src/Resources/Resources/RoleAssignments/NewAzureRoleAssignmentCommand.cs b/src/Resources/Resources/RoleAssignments/NewAzureRoleAssignmentCommand.cs index 5fcff70cc0dc..58d7fb4b0cba 100644 --- a/src/Resources/Resources/RoleAssignments/NewAzureRoleAssignmentCommand.cs +++ b/src/Resources/Resources/RoleAssignments/NewAzureRoleAssignmentCommand.cs @@ -17,11 +17,11 @@ using Microsoft.Azure.Commands.Resources.Models; using Microsoft.Azure.Commands.Resources.Models.Authorization; using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; using Microsoft.WindowsAzure.Commands.Utilities.Common; + using Newtonsoft.Json; + using System; -using System.Globalization; using System.IO; using System.Management.Automation; @@ -30,7 +30,6 @@ namespace Microsoft.Azure.Commands.Resources /// /// Creates new role assignment. /// - [GenericBreakingChange(BreakingChangeMSGraphMigration)] [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoleAssignment", DefaultParameterSetName = ParameterSet.Empty), OutputType(typeof(PSRoleAssignment))] public class NewAzureRoleAssignmentCommand : ResourcesBaseCmdlet { diff --git a/src/Resources/Resources/RoleAssignments/RemoveAzureRoleAssignmentCommand.cs b/src/Resources/Resources/RoleAssignments/RemoveAzureRoleAssignmentCommand.cs index 07451dfb2bd8..45a42935865e 100644 --- a/src/Resources/Resources/RoleAssignments/RemoveAzureRoleAssignmentCommand.cs +++ b/src/Resources/Resources/RoleAssignments/RemoveAzureRoleAssignmentCommand.cs @@ -17,11 +17,12 @@ using Microsoft.Azure.Commands.Resources.Models; using Microsoft.Azure.Commands.Resources.Models.Authorization; using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; using Microsoft.WindowsAzure.Commands.Utilities.Common; + using System; using System.Collections.Generic; using System.Management.Automation; + using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; namespace Microsoft.Azure.Commands.Resources @@ -29,7 +30,6 @@ namespace Microsoft.Azure.Commands.Resources /// /// Removes a given role assignment. /// - [GenericBreakingChange(BreakingChangeMSGraphMigration)] [Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoleAssignment", SupportsShouldProcess = true, DefaultParameterSetName = ParameterSet.Empty), OutputType(typeof(PSRoleAssignment))] public class RemoveAzureRoleAssignmentCommand : ResourcesBaseCmdlet { diff --git a/src/Resources/Resources/RoleAssignments/SetAzureRoleAssignmentCommand.cs b/src/Resources/Resources/RoleAssignments/SetAzureRoleAssignmentCommand.cs index b0179cd11d5d..5675dcaa2f45 100644 --- a/src/Resources/Resources/RoleAssignments/SetAzureRoleAssignmentCommand.cs +++ b/src/Resources/Resources/RoleAssignments/SetAzureRoleAssignmentCommand.cs @@ -15,15 +15,15 @@ using Microsoft.Azure.Commands.ActiveDirectory; using Microsoft.Azure.Commands.Resources.Models; using Microsoft.Azure.Commands.Resources.Models.Authorization; -using Microsoft.Azure.Management.Internal.Network.Version2017_10_01.Models; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; using Microsoft.WindowsAzure.Commands.Utilities.Common; + using Newtonsoft.Json; + using System; -using System.Collections.Generic; using System.IO; using System.Linq; using System.Management.Automation; + using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; namespace Microsoft.Azure.Commands.Resources @@ -31,7 +31,6 @@ namespace Microsoft.Azure.Commands.Resources /// /// Updates an existing role assignment. /// - [GenericBreakingChange(BreakingChangeMSGraphMigration)] [Cmdlet("Set", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoleAssignment", SupportsShouldProcess = true, DefaultParameterSetName = ParameterSet.RoleAssignment), OutputType(typeof(PSRoleAssignment))] public class SetAzureRoleAssignmentCommand : ResourcesBaseCmdlet { diff --git a/src/Resources/Resources/RoleDefinitions/GetAzureRoleDefinitionCommand.cs b/src/Resources/Resources/RoleDefinitions/GetAzureRoleDefinitionCommand.cs index 47705d883ee2..b20b7b52165b 100644 --- a/src/Resources/Resources/RoleDefinitions/GetAzureRoleDefinitionCommand.cs +++ b/src/Resources/Resources/RoleDefinitions/GetAzureRoleDefinitionCommand.cs @@ -16,19 +16,17 @@ using Microsoft.Azure.Commands.Resources.Models; using Microsoft.Azure.Commands.Resources.Models.Authorization; using Microsoft.WindowsAzure.Commands.Common; + using System; using System.Collections.Generic; using System.Linq; using System.Management.Automation; -using Microsoft.Azure.Commands.Common.Strategies; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; namespace Microsoft.Azure.Commands.Resources { /// /// Get the available role Definitions for certain resource types. /// - [GenericBreakingChange(BreakingChangeMSGraphMigration)] [Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoleDefinition", DefaultParameterSetName = ParameterSet.RoleDefinitionName), OutputType(typeof(PSRoleDefinition))] public class GetAzureRoleDefinitionCommand : ResourcesBaseCmdlet { diff --git a/src/Resources/Resources/RoleDefinitions/NewAzureRoleDefinitionCommand.cs b/src/Resources/Resources/RoleDefinitions/NewAzureRoleDefinitionCommand.cs index a966d9ab6e31..2a40a19cba4f 100644 --- a/src/Resources/Resources/RoleDefinitions/NewAzureRoleDefinitionCommand.cs +++ b/src/Resources/Resources/RoleDefinitions/NewAzureRoleDefinitionCommand.cs @@ -15,9 +15,10 @@ using Microsoft.Azure.Commands.ActiveDirectory; using Microsoft.Azure.Commands.Resources.Models; using Microsoft.Azure.Commands.Resources.Models.Authorization; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; using Microsoft.WindowsAzure.Commands.Utilities.Common; + using Newtonsoft.Json; + using System; using System.IO; using System.Management.Automation; @@ -27,7 +28,6 @@ namespace Microsoft.Azure.Commands.Resources /// /// Creates a new role definition. /// - [GenericBreakingChange(BreakingChangeMSGraphMigration)] [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoleDefinition"), OutputType(typeof(PSRoleDefinition))] public class NewAzureRoleDefinitionCommand : ResourcesBaseCmdlet { diff --git a/src/Resources/Resources/RoleDefinitions/RemoveAzureRoleDefinitionCommand.cs b/src/Resources/Resources/RoleDefinitions/RemoveAzureRoleDefinitionCommand.cs index c2b785192140..a9799ebd8a10 100644 --- a/src/Resources/Resources/RoleDefinitions/RemoveAzureRoleDefinitionCommand.cs +++ b/src/Resources/Resources/RoleDefinitions/RemoveAzureRoleDefinitionCommand.cs @@ -16,10 +16,11 @@ using Microsoft.Azure.Commands.Resources.Models; using Microsoft.Azure.Commands.Resources.Models.Authorization; using Microsoft.WindowsAzure.Commands.Common; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; using Microsoft.WindowsAzure.Commands.Utilities.Common; + using System; using System.Management.Automation; + using ProjectResources = Microsoft.Azure.Commands.Resources.Properties.Resources; namespace Microsoft.Azure.Commands.Resources @@ -27,7 +28,6 @@ namespace Microsoft.Azure.Commands.Resources /// /// Deletes a given role definition. /// - [GenericBreakingChange(BreakingChangeMSGraphMigration)] [Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoleDefinition", SupportsShouldProcess = true,DefaultParameterSetName = ParameterSet.RoleDefinitionId), OutputType(typeof(bool))] public class RemoveAzureRoleDefinitionCommand : ResourcesBaseCmdlet { diff --git a/src/Resources/Resources/RoleDefinitions/SetAzureRoleDefinitionCommand.cs b/src/Resources/Resources/RoleDefinitions/SetAzureRoleDefinitionCommand.cs index 92bac9423c16..5c163ca24ea1 100644 --- a/src/Resources/Resources/RoleDefinitions/SetAzureRoleDefinitionCommand.cs +++ b/src/Resources/Resources/RoleDefinitions/SetAzureRoleDefinitionCommand.cs @@ -15,9 +15,10 @@ using Microsoft.Azure.Commands.ActiveDirectory; using Microsoft.Azure.Commands.Resources.Models; using Microsoft.Azure.Commands.Resources.Models.Authorization; -using Microsoft.WindowsAzure.Commands.Common.CustomAttributes; using Microsoft.WindowsAzure.Commands.Utilities.Common; + using Newtonsoft.Json; + using System.IO; using System.Management.Automation; @@ -26,7 +27,6 @@ namespace Microsoft.Azure.Commands.Resources /// /// Updates an existing role definition. /// - [GenericBreakingChange(BreakingChangeMSGraphMigration)] [Cmdlet("Set", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoleDefinition"), OutputType(typeof(PSRoleDefinition))] public class SetAzureRoleDefinitionCommand : ResourcesBaseCmdlet { diff --git a/src/Resources/Resources/help/Add-AzADGroupMember.md b/src/Resources/Resources/help/Add-AzADGroupMember.md deleted file mode 100644 index 0197b687e5c2..000000000000 --- a/src/Resources/Resources/help/Add-AzADGroupMember.md +++ /dev/null @@ -1,232 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -online version: https://docs.microsoft.com/powershell/module/az.resources/add-azadgroupmember -schema: 2.0.0 ---- - -# Add-AzADGroupMember - -## SYNOPSIS -Adds a user to an existing AD group. - -## SYNTAX - -### MemberObjectIdWithGroupObjectId (Default) -``` -Add-AzADGroupMember -MemberObjectId -TargetGroupObjectId [-PassThru] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### MemberObjectIdWithGroupDisplayName -``` -Add-AzADGroupMember -MemberObjectId -TargetGroupDisplayName [-PassThru] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### MemberObjectIdWithGroupObject -``` -Add-AzADGroupMember -MemberObjectId -TargetGroupObject [-PassThru] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### MemberUPNWithGroupDisplayNameParameterSet -``` -Add-AzADGroupMember -MemberUserPrincipalName -TargetGroupDisplayName [-PassThru] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### MemberUPNWithGroupObjectParameterSet -``` -Add-AzADGroupMember -MemberUserPrincipalName -TargetGroupObject [-PassThru] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### MemberUPNWithGroupObjectIdParameterSet -``` -Add-AzADGroupMember -MemberUserPrincipalName -TargetGroupObjectId [-PassThru] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Adds a user to an existing AD group. - -## EXAMPLES - -### Example 1: Add a user to a group by object id - -```powershell -PS C:\> Add-AzADGroupMember -MemberObjectId D9076BBC-D62C-4105-9C78-A7F5BC4A3405 -TargetGroupObjectId 85F89C90-780E-4AA6-9F4F-6F268D322EEE -``` - -Adds the user with object id 'D9076BBC-D62C-4105-9C78-A7F5BC4A3405' to the group with object id '85F89C90-780E-4AA6-9F4F-6F268D322EEE'. - -### Example 2: Add a user to a group by piping - -```powershell -PS C:\> Get-AzADGroup -ObjectId 85F89C90-780E-4AA6-9F4F-6F268D322EEE | Add-AzADGroupMember -MemberObjectId D9076BBC-D62C-4105-9C78-A7F5BC4A3405 -``` - -Gets the group with object id '85F89C90-780E-4AA6-9F4F-6F268D322EEE' and pipes it to the Add-AzADGroupMember cmdlet to add the user to that group. - -### Example 3: Add a user to a group by principal name - -```powershell -PS C:\> Add-AzADGroupMember -MemberUserPrincipalName "myemail@domain.com" -TargetGroupDisplayName "MyGroupDisplayName" -PS C:\> Get-AzADGroupMember -GroupDisplayName "MyGroupDisplayName" -``` - -Adds an user to a group and list the members of the group. - -## PARAMETERS - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with Azure. - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -MemberObjectId -The object id of the member. - -```yaml -Type: System.String[] -Parameter Sets: MemberObjectIdWithGroupObjectId, MemberObjectIdWithGroupDisplayName, MemberObjectIdWithGroupObject -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -MemberUserPrincipalName -The UPN of the member(s) to add to the group. - -```yaml -Type: System.String[] -Parameter Sets: MemberUPNWithGroupDisplayNameParameterSet, MemberUPNWithGroupObjectParameterSet, MemberUPNWithGroupObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -PassThru -Specifying this will return true if the command was successful. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -TargetGroupDisplayName -The display name of the group to add the member(s) to. - -```yaml -Type: System.String -Parameter Sets: MemberObjectIdWithGroupDisplayName, MemberUPNWithGroupDisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -TargetGroupObject -The object representation of the group to add the member(s) to. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADGroup -Parameter Sets: MemberObjectIdWithGroupObject, MemberUPNWithGroupObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -TargetGroupObjectId -The object id of the group to add the member(s) to. - -```yaml -Type: System.String -Parameter Sets: MemberObjectIdWithGroupObjectId, MemberUPNWithGroupObjectIdParameterSet -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. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADGroup - -## OUTPUTS - -### System.Boolean - -## NOTES - -## RELATED LINKS diff --git a/src/Resources/Resources/help/Get-AzADAppCredential.md b/src/Resources/Resources/help/Get-AzADAppCredential.md deleted file mode 100644 index 32fede0817a6..000000000000 --- a/src/Resources/Resources/help/Get-AzADAppCredential.md +++ /dev/null @@ -1,160 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: 6AC9DA05-756D-4D59-BD97-DBAAFBB3C7AC -online version: https://docs.microsoft.com/powershell/module/az.resources/get-azadappcredential -schema: 2.0.0 ---- - -# Get-AzADAppCredential - -## SYNOPSIS -Retrieves a list of credentials associated with an application. - -## SYNTAX - -### ApplicationObjectIdParameterSet (Default) -``` -Get-AzADAppCredential -ObjectId [-DefaultProfile ] [] -``` - -### ApplicationIdParameterSet -``` -Get-AzADAppCredential -ApplicationId [-DefaultProfile ] [] -``` - -### DisplayNameParameterSet -``` -Get-AzADAppCredential -DisplayName [-DefaultProfile ] [] -``` - -### ApplicationObjectParameterSet -``` -Get-AzADAppCredential -ApplicationObject [-DefaultProfile ] - [] -``` - -## DESCRIPTION -The Get-AzADAppCredential cmdlet can be used to retrieve a list of credentials associated with an application. -This command will retrieve all of the credential properties (but not the credential value) associated with the application. - -## EXAMPLES - -### Example 1: Get application credentials by object id - -```powershell -PS C:\> Get-AzADAppCredential -ObjectId 1f99cf81-0146-4f4e-beae-2007d0668476 -``` - -Returns a list of credentials associated with the application having object id '1f99cf81-0146-4f4e-beae-2007d0668476'. - -### Example 2: Get application credentials by piping - -```powershell -PS C:\> Get-AzADApplication -ObjectId 1f99cf81-0146-4f4e-beae-2007d0668476 | Get-AzADAppCredential -``` - -Gets the application with object id '1f99cf81-0146-4f4e-beae-2007d0668476' and pipes it to the Get-AzADAppCredential cmdlet to list all of the credentials for that application. - -## PARAMETERS - -### -ApplicationId -The id of the application to retrieve credentials from. - -```yaml -Type: System.Guid -Parameter Sets: ApplicationIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ApplicationObject -The application object to retrieve credentials from. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADApplication -Parameter Sets: ApplicationObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name of the application. - -```yaml -Type: System.String -Parameter Sets: DisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the application to retrieve credentials from. - -```yaml -Type: System.String -Parameter Sets: ApplicationObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### System.Guid - -### Microsoft.Azure.Commands.ActiveDirectory.PSADApplication - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADCredential - -## NOTES - -## RELATED LINKS - -[New-AzADAppCredential](./New-AzADAppCredential.md) - -[Remove-AzADAppCredential](./Remove-AzADAppCredential.md) - -[Get-AzADApplication](./Get-AzADApplication.md) - diff --git a/src/Resources/Resources/help/Get-AzADApplication.md b/src/Resources/Resources/help/Get-AzADApplication.md deleted file mode 100644 index f68d7596a396..000000000000 --- a/src/Resources/Resources/help/Get-AzADApplication.md +++ /dev/null @@ -1,256 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: 66AC5120-80B1-46F2-AA51-132BF361602E -online version: https://docs.microsoft.com/powershell/module/az.resources/get-azadapplication -schema: 2.0.0 ---- - -# Get-AzADApplication - -## SYNOPSIS -Lists existing azure active directory applications. - -## SYNTAX - -### EmptyParameterSet (Default) -``` -Get-AzADApplication [-DefaultProfile ] [-IncludeTotalCount] [-Skip ] - [-First ] [] -``` - -### ApplicationObjectIdParameterSet -``` -Get-AzADApplication -ObjectId [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### ApplicationIdParameterSet -``` -Get-AzADApplication -ApplicationId [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### SearchStringParameterSet -``` -Get-AzADApplication -DisplayNameStartWith [-DefaultProfile ] - [-IncludeTotalCount] [-Skip ] [-First ] [] -``` - -### DisplayNameParameterSet -``` -Get-AzADApplication -DisplayName [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### ApplicationIdentifierUriParameterSet -``` -Get-AzADApplication -IdentifierUri [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -## DESCRIPTION -Lists existing azure active directory applications. -Application lookup can be done by ObjectId, ApplicationId, IdentifierUri or DisplayName. -If no parameter is provided, it fetches all applications under the tenant. - -## EXAMPLES - -### Example 1: List all applications - -```powershell -PS C:\> Get-AzADApplication -``` - -Lists all the applications under a tenant. - -### Example 2: List applications using paging - -```powershell -PS C:\> Get-AzADApplication -First 100 -``` - -Lists the first 100 applications under a tenant. - -### Example 3: Get application by identifier URI - -```powershell -PS C:\> Get-AzADApplication -IdentifierUri http://mySecretApp1 -``` - -Gets the application with identifier uri as "http://mySecretApp1". - -### Example 4: Get application by object id - -```powershell -PS C:\> Get-AzADApplication -ObjectId 39e64ec6-569b-4030-8e1c-c3c519a05d69 -``` - -Gets the application with the object id '39e64ec6-569b-4030-8e1c-c3c519a05d69'. - -## PARAMETERS - -### -ApplicationId -The application id of the application to fetch. - -```yaml -Type: System.Guid -Parameter Sets: ApplicationIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name of the application. - -```yaml -Type: System.String -Parameter Sets: DisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -DisplayNameStartWith -Fetch all applications starting with the display name. - -```yaml -Type: System.String -Parameter Sets: SearchStringParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -IdentifierUri -Unique identifier Uri of the application to fetch. - -```yaml -Type: System.String -Parameter Sets: ApplicationIdentifierUriParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the application to fetch. - -```yaml -Type: System.String -Parameter Sets: ApplicationObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -IncludeTotalCount -Reports the number of objects in the data set. Currently, this parameter does nothing. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Skip -Ignores the first N objects and then gets the remaining objects. - -```yaml -Type: System.UInt64 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -First -The maximum number of objects to return. - -```yaml -Type: System.UInt64 -Parameter Sets: (All) -Aliases: - -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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### System.Guid - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADApplication - -## NOTES - -## RELATED LINKS - -[Remove-AzADAppCredential](./Remove-AzADAppCredential.md) - -[New-AzADAppCredential](./New-AzADAppCredential.md) - -[Get-AzADAppCredential](./Get-AzADAppCredential.md) - -[Remove-AzADApplication](./Remove-AzADApplication.md) - -[New-AzADApplication](./New-AzADApplication.md) - -[Update-AzADApplication](./Update-AzADApplication.md) - diff --git a/src/Resources/Resources/help/Get-AzADGroup.md b/src/Resources/Resources/help/Get-AzADGroup.md deleted file mode 100644 index baec80c08ec5..000000000000 --- a/src/Resources/Resources/help/Get-AzADGroup.md +++ /dev/null @@ -1,217 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: 85DDA491-7A7D-4217-B0E3-72CDC3787889 -online version: https://docs.microsoft.com/powershell/module/az.resources/get-azadgroup -schema: 2.0.0 ---- - -# Get-AzADGroup - -## SYNOPSIS -Filters active directory groups. - -## SYNTAX - -### EmptyParameterSet (Default) -``` -Get-AzADGroup [-ObjectId ] [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### SearchStringParameterSet -``` -Get-AzADGroup -DisplayNameStartsWith [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### DisplayNameParameterSet -``` -Get-AzADGroup -DisplayName [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### ObjectIdParameterSet -``` -Get-AzADGroup -ObjectId [-DefaultProfile ] [-IncludeTotalCount] [-Skip ] - [-First ] [] -``` - -## DESCRIPTION -Filters active directory groups. - -## EXAMPLES - -### Example 1: List all AD groups -```powershell -PS C:\> Get-AzADGroup -``` - -Lists all AD groups in a tenant. - -### Example 2: List all AD groups using paging - -```powershell -PS C:\> Get-AzADGroup -First 100 -``` - -Lists the first 100 AD groups in a tenant. - -### Example 3: Get AD group by object id - -```powershell -PS C:\> Get-AzADGroup -ObjectId 85F89C90-780E-4AA6-9F4F-6F268D322EEE -``` - -Gets an AD group with object id '85F89C90-780E-4AA6-9F4F-6F268D322EEE'. - -### Example 4: List groups by search string - -```powershell -PS C:\> Get-AzADGroup -SearchString Joe -``` - -Lists all AD groups whose display name begins with 'Joe'. - -## PARAMETERS - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name of the group. - -```yaml -Type: System.String -Parameter Sets: DisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayNameStartsWith -Used to find groups that begin with the provided string. - -```yaml -Type: System.String -Parameter Sets: SearchStringParameterSet -Aliases: SearchString - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ObjectId -Object id of the group. - -```yaml -Type: System.Guid -Parameter Sets: EmptyParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.Guid -Parameter Sets: ObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -IncludeTotalCount -Reports the number of objects in the data set. Currently, this parameter does nothing. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Skip -Ignores the first N objects and then gets the remaining objects. - -```yaml -Type: System.UInt64 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -First -The maximum number of objects to return. - -```yaml -Type: System.UInt64 -Parameter Sets: (All) -Aliases: - -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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### System.Guid - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADGroup - -## NOTES - -## RELATED LINKS - -[Get-AzADUser](./Get-AzADUser.md) - -[Get-AzADServicePrincipal](./Get-AzADServicePrincipal.md) - -[Get-AzADGroupMember](./Get-AzADGroupMember.md) - diff --git a/src/Resources/Resources/help/Get-AzADGroupMember.md b/src/Resources/Resources/help/Get-AzADGroupMember.md deleted file mode 100644 index 594acb9e59c7..000000000000 --- a/src/Resources/Resources/help/Get-AzADGroupMember.md +++ /dev/null @@ -1,190 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: 52C5CD8B-2489-4FE6-9F33-B3350531CD8E -online version: https://docs.microsoft.com/powershell/module/az.resources/get-azadgroupmember -schema: 2.0.0 ---- - -# Get-AzADGroupMember - -## SYNOPSIS -Lists members of an AD group in the current tenant. - -## SYNTAX - -### ObjectIdParameterSet (Default) -``` -Get-AzADGroupMember [-GroupObjectId ] [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### DisplayNameParameterSet -``` -Get-AzADGroupMember -GroupDisplayName [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### GroupObjectParameterSet -``` -Get-AzADGroupMember -GroupObject [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -## DESCRIPTION -Lists members of an AD group in the current tenant. - -## EXAMPLES - -### Example 1: List members by AD group object id - -```powershell -PS C:\> Get-AzADGroupMember -GroupObjectId 85F89C90-780E-4AA6-9F4F-6F268D322EEE -``` - -Lists members of the AD group with object id '85F89C90-780E-4AA6-9F4F-6F268D322EEE'. - -### Example 2: List members by AD group object id using paging - -```powershell -PS C:\> Get-AzADGroupMember -GroupObjectId 85F89C90-780E-4AA6-9F4F-6F268D322EEE -First 100 -``` - -Lists the first 100 members of the AD group with object id '85F89C90-780E-4AA6-9F4F-6F268D322EEE'. - -### Example 3: List members by piping - -```powershell -PS C:\> Get-AzADGroup -ObjectId 85F89C90-780E-4AA6-9F4F-6F268D322EEE | Get-AzADGroupMember -``` - -Gets the AD group with object id '85F89C90-780E-4AA6-9F4F-6F268D322EEE' and pipes it to the Get-AzADGroupMember cmdlet to list all members in that group. - -## PARAMETERS - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -GroupDisplayName -The display name of the group. - -```yaml -Type: System.String -Parameter Sets: DisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -GroupObject -The group object that you are listing members from. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADGroup -Parameter Sets: GroupObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -GroupObjectId -Object Id of the group. - -```yaml -Type: System.String -Parameter Sets: ObjectIdParameterSet -Aliases: Id, ObjectId - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -IncludeTotalCount -Reports the number of objects in the data set. Currently, this parameter does nothing. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Skip -Ignores the first N objects and then gets the remaining objects. - -```yaml -Type: System.UInt64 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -First -The maximum number of objects to return. - -```yaml -Type: System.UInt64 -Parameter Sets: (All) -Aliases: - -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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### Microsoft.Azure.Commands.ActiveDirectory.PSADGroup - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADObject - -## NOTES - -## RELATED LINKS - -[Get-AzADUser](./Get-AzADUser.md) - -[Get-AzADServicePrincipal](./Get-AzADServicePrincipal.md) - diff --git a/src/Resources/Resources/help/Get-AzADServicePrincipal.md b/src/Resources/Resources/help/Get-AzADServicePrincipal.md deleted file mode 100644 index 3bd3a9a2d7a7..000000000000 --- a/src/Resources/Resources/help/Get-AzADServicePrincipal.md +++ /dev/null @@ -1,283 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: 4DC26C26-6162-4A15-BFCB-4D2B6B52DD81 -online version: https://docs.microsoft.com/powershell/module/az.resources/get-azadserviceprincipal -schema: 2.0.0 ---- - -# Get-AzADServicePrincipal - -## SYNOPSIS -Filters active directory service principals. - -## SYNTAX - -### EmptyParameterSet (Default) -``` -Get-AzADServicePrincipal [-DefaultProfile ] [-IncludeTotalCount] [-Skip ] - [-First ] [] -``` - -### SearchStringParameterSet -``` -Get-AzADServicePrincipal -DisplayNameBeginsWith [-DefaultProfile ] - [-IncludeTotalCount] [-Skip ] [-First ] [] -``` - -### DisplayNameParameterSet -``` -Get-AzADServicePrincipal -DisplayName [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### ObjectIdParameterSet -``` -Get-AzADServicePrincipal -ObjectId [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### ApplicationIdParameterSet -``` -Get-AzADServicePrincipal -ApplicationId [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### ApplicationObjectParameterSet -``` -Get-AzADServicePrincipal -ApplicationObject [-DefaultProfile ] - [-IncludeTotalCount] [-Skip ] [-First ] [] -``` - -### SPNParameterSet -``` -Get-AzADServicePrincipal -ServicePrincipalName [-DefaultProfile ] - [-IncludeTotalCount] [-Skip ] [-First ] [] -``` - -## DESCRIPTION -Filters active directory service principals. - -## EXAMPLES - -### Example 1: List AD service principals - -```powershell -PS C:\> Get-AzADServicePrincipal -``` - -Lists all AD service principals in a tenant. - -### Example 2: List AD service principals using paging - -```powershell -PS C:\> Get-AzADServicePrincipal -First 100 -``` - -Lists the first 100 AD service principals in a tenant. - -### Example 3: List service principals by SPN - -```powershell -PS C:\> Get-AzADServicePrincipal -ServicePrincipalName 36f81fc3-b00f-48cd-8218-3879f51ff39f -``` - -Lists service principals with the SPN '36f81fc3-b00f-48cd-8218-3879f51ff39f'. - -### Example 4: List service principals by search string - -```powershell -PS C:\> Get-AzADServicePrincipal -SearchString "Web" -``` - -Lists all AD service principals whose display name start with "Web". - -### Example 5: List service principals by piping - -```powershell -PS C:\> Get-AzADApplication -ObjectId 39e64ec6-569b-4030-8e1c-c3c519a05d69 | Get-AzADServicePrincipal -``` - -Gets the AD application with object id '39e64ec6-569b-4030-8e1c-c3c519a05d69' and pipes it to the Get-AzADServicePrincipal cmdlet to list all service principals for that application. - -## PARAMETERS - -### -ApplicationId -The service principal application id. - -```yaml -Type: System.Guid -Parameter Sets: ApplicationIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ApplicationObject -The application object whose service principal is being retrieved. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADApplication -Parameter Sets: ApplicationObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The service principal display name. - -```yaml -Type: System.String -Parameter Sets: DisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -DisplayNameBeginsWith -The service principal search string. - -```yaml -Type: System.String -Parameter Sets: SearchStringParameterSet -Aliases: SearchString - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ObjectId -Object id of the service principal. - -```yaml -Type: System.String -Parameter Sets: ObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ServicePrincipalName -SPN of the service. - -```yaml -Type: System.String -Parameter Sets: SPNParameterSet -Aliases: SPN - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -IncludeTotalCount -Reports the number of objects in the data set. Currently, this parameter does nothing. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Skip -Ignores the first N objects and then gets the remaining objects. - -```yaml -Type: System.UInt64 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -First -The maximum number of objects to return. - -```yaml -Type: System.UInt64 -Parameter Sets: (All) -Aliases: - -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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### System.Guid - -### Microsoft.Azure.Commands.ActiveDirectory.PSADApplication - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal - -## NOTES - -## RELATED LINKS - -[New-AzADServicePrincipal](./New-AzADServicePrincipal.md) - -[Update-AzADServicePrincipal](./Update-AzADServicePrincipal.md) - -[Remove-AzADServicePrincipal](./Remove-AzADServicePrincipal.md) - -[Get-AzADApplication](./Get-AzADApplication.md) - -[Get-AzADSpCredential](./Get-AzADSpCredential.md) - diff --git a/src/Resources/Resources/help/Get-AzADSpCredential.md b/src/Resources/Resources/help/Get-AzADSpCredential.md deleted file mode 100644 index 87fb7b59cc07..000000000000 --- a/src/Resources/Resources/help/Get-AzADSpCredential.md +++ /dev/null @@ -1,167 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: 7690143F-5F09-4739-9F66-B2ACDF8305F4 -online version: https://docs.microsoft.com/powershell/module/az.resources/get-azadspcredential -schema: 2.0.0 ---- - -# Get-AzADSpCredential - -## SYNOPSIS -Retrieves a list of credentials associated with a service principal. - -## SYNTAX - -### ObjectIdParameterSet (Default) -``` -Get-AzADSpCredential -ObjectId [-DefaultProfile ] [] -``` - -### SPNParameterSet -``` -Get-AzADSpCredential -ServicePrincipalName [-DefaultProfile ] - [] -``` - -### DisplayNameParameterSet -``` -Get-AzADSpCredential -DisplayName [-DefaultProfile ] [] -``` - -### SPNObjectParameterSet -``` -Get-AzADSpCredential -ServicePrincipalObject [-DefaultProfile ] - [] -``` - -## DESCRIPTION -The Get-AzADSpCredential cmdlet can be used to retrieve a list of credentials associated with a service principal. -This command will retrieve all of the credential properties (but not the credential value) associated with the service principal. - -## EXAMPLES - -### Example 1: List credentials by SPN - -```powershell -PS C:\> Get-AzADSpCredential -ServicePrincipalName http://test12345 -``` - -Returns a list of credentials associated with the service principal with SPN 'http://test12345'. - -### Example 2: List credentials by object id - -```powershell -PS C:\> Get-AzADSpCredential -ObjectId 58e28616-99cc-4da4-b705-7672130e1047 -``` - -Returns a list of credentials associated with the service principal with object id "58e28616-99cc-4da4-b705-7672130e1047". - -### Example 3: List credentials by piping - -```powershell -PS C:\> Get-AzADServicePrincipal -ObjectId 58e28616-99cc-4da4-b705-7672130e1047 | Get-AzADSpCredential -``` - -Gets the service principal with object id "58e28616-99cc-4da4-b705-7672130e1047" and pipes it to the Get-AzADSpCredential cmdlet to list all credentials for that service principal. - -## PARAMETERS - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name of the service principal - -```yaml -Type: System.String -Parameter Sets: DisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the service principal to retrieve credentials from. - -```yaml -Type: System.String -Parameter Sets: ObjectIdParameterSet -Aliases: Id - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ServicePrincipalName -The name (SPN) of the service principal to retrieve credentials from. - -```yaml -Type: System.String -Parameter Sets: SPNParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ServicePrincipalObject -The service principal object to retrieve the credentials from. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal -Parameter Sets: SPNObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADCredential - -## NOTES - -## RELATED LINKS - -[New-AzADSpCredential](./New-AzADSpCredential.md) - -[Remove-AzADSpCredential](./Remove-AzADSpCredential.md) - -[Get-AzADServicePrincipal](./Get-AzADServicePrincipal.md) - diff --git a/src/Resources/Resources/help/Get-AzADUser.md b/src/Resources/Resources/help/Get-AzADUser.md deleted file mode 100644 index 4d94dc072d52..000000000000 --- a/src/Resources/Resources/help/Get-AzADUser.md +++ /dev/null @@ -1,258 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: BF254F2F-F658-45CC-8AC8-53FF96CFCAAD -online version: https://docs.microsoft.com/powershell/module/az.resources/get-azaduser -schema: 2.0.0 ---- - -# Get-AzADUser - -## SYNOPSIS -Filters active directory users. - -## SYNTAX - -### EmptyParameterSet (Default) -``` -Get-AzADUser [-UserPrincipalName ] [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### SearchStringParameterSet -``` -Get-AzADUser -StartsWith [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### DisplayNameParameterSet -``` -Get-AzADUser -DisplayName [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### ObjectIdParameterSet -``` -Get-AzADUser -ObjectId [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### UPNParameterSet -``` -Get-AzADUser -UserPrincipalName [-DefaultProfile ] [-IncludeTotalCount] - [-Skip ] [-First ] [] -``` - -### MailParameterSet -``` -Get-AzADUser -Mail [-DefaultProfile ] [-IncludeTotalCount] [-Skip ] - [-First ] [] -``` - -## DESCRIPTION -Filters active directory users. - -## EXAMPLES - -### Example 1: List all users - -```powershell -PS C:\> Get-AzADUser -``` - -Lists all AD users in a tenant. - -### Example 2: List all users using paging - -```powershell -PS C:\> Get-AzADUser -First 100 -``` - -Lists the first 100 AD users in a tenant. - -### Example 3: Get AD user by user principal name - -```powershell -PS C:\> Get-AzADUser -UserPrincipalName foo@domain.com -``` - -Gets the AD user with user principal name "foo@domain.com". - -### Example 4: List by search string - -```powershell -PS C:\> Get-AzADUser -SearchString Joe -``` - -Lists all AD users whose display name starts with "Joe". - -## PARAMETERS - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name of the user. - -```yaml -Type: System.String -Parameter Sets: DisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Mail -The user mail. - -```yaml -Type: System.String -Parameter Sets: MailParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ObjectId -Object id of the user. - -```yaml -Type: System.String -Parameter Sets: ObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -StartsWith -Used to find users that begin with the provided string. - -```yaml -Type: System.String -Parameter Sets: SearchStringParameterSet -Aliases: SearchString - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -UserPrincipalName -UPN of the user. - -```yaml -Type: System.String -Parameter Sets: EmptyParameterSet -Aliases: UPN - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.String -Parameter Sets: UPNParameterSet -Aliases: UPN - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -IncludeTotalCount -Reports the number of objects in the data set. Currently, this parameter does nothing. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Skip -Ignores the first N objects and then gets the remaining objects. - -```yaml -Type: System.UInt64 -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -First -The maximum number of objects to return. - -```yaml -Type: System.UInt64 -Parameter Sets: (All) -Aliases: - -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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADUser - -## NOTES - -## RELATED LINKS - -[New-AzADUser](./New-AzADUser.md) - -[Update-AzADUser](./Update-AzADUser.md) - -[Remove-AzADUser](./Remove-AzADUser.md) - diff --git a/src/Resources/Resources/help/Get-AzDenyAssignment.md b/src/Resources/Resources/help/Get-AzDenyAssignment.md index f54449a8be6f..6ef4d23f6979 100644 --- a/src/Resources/Resources/help/Get-AzDenyAssignment.md +++ b/src/Resources/Resources/help/Get-AzDenyAssignment.md @@ -153,7 +153,7 @@ List all deny assignments in the subscription ``` PS C:\> Get-AzDenyAssignment -Id : 22704996-fbd0-4ab1-8625-722d897825d2 +Id : /subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/providers/Microsoft.Authorization/denyAssignments/22704996-fbd0-4ab1-8625-722d897825d2 DenyAssignmentName : Test deny assignment 1 Description : Test deny assignment for PS cmdlets Actions : {foo/*} @@ -174,7 +174,7 @@ ExcludePrincipals : { } IsSystemProtected : True -Id : 43af7d0c-0bf8-407f-96c0-96a29d076431 +Id : /subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourcegroups/testRG/providers/Microsoft.Authorization/denyAssignments/43af7d0c-0bf8-407f-96c0-96a29d076431 DenyAssignmentName : Test deny assignment 2 Description : Test deny assignment for PS cmdlets Actions : {foo/*} @@ -203,7 +203,7 @@ Gets all deny assignments made to user john.doe@contoso.com at the scope testRG ``` PS C:\> Get-AzDenyAssignment -ResourceGroupName testRG -SignInName john.doe@contoso.com -Id : 22704996-fbd0-4ab1-8625-722d897825d2 +Id : /subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/providers/Microsoft.Authorization/denyAssignments/22704996-fbd0-4ab1-8625-722d897825d2 DenyAssignmentName : Test deny assignment 1 Description : Test deny assignment for PS cmdlets Actions : {foo/*} @@ -220,7 +220,7 @@ Principals : { ExcludePrincipals : {} IsSystemProtected : True -Id : 43af7d0c-0bf8-407f-96c0-96a29d076431 +Id : /subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourcegroups/testRG/providers/Microsoft.Authorization/denyAssignments/43af7d0c-0bf8-407f-96c0-96a29d076431 DenyAssignmentName : Test deny assignment Description : Test deny assignment for PS cmdlets Actions : {foo/*} @@ -249,7 +249,7 @@ Gets all deny assignments of the specified service principal ``` PS C:\> Get-AzDenyAssignment -ServicePrincipalName 'http://testapp1.com' -Id : 43af7d0c-0bf8-407f-96c0-96a29d076431 +Id : /subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourcegroups/testRG/providers/Microsoft.Authorization/denyAssignments/43af7d0c-0bf8-407f-96c0-96a29d076431 DenyAssignmentName : Test deny assignment 1 Description : Test deny assignment for PS cmdlets Actions : {foo/*} @@ -266,7 +266,7 @@ Principals : { ExcludePrincipals : {} IsSystemProtected : True -Id : 94e3d9da-3700-4113-aab4-15f6c173d794 +Id : /subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourceGroups/testRG/providers/Microsoft.Web/sites/site1/providers/Microsoft.Authorization/denyAssignments/94e3d9da-3700-4113-aab4-15f6c173d794 DenyAssignmentName : Test deny assignment 2 Description : Test deny assignment for PS cmdlets Actions : {foo/*} @@ -295,7 +295,7 @@ Gets deny assignments at the 'site1' website scope. ``` PS C:\> Get-AzDenyAssignment -Scope '/subscriptions/96231a05-34ce-4eb4-aa6a-70759cbb5e83/resourcegroups/testRG/providers/Microsoft.Web/sites/site1' -Id : 43af7d0c-0bf8-407f-96c0-96a29d076431 +Id : /subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourcegroups/testRG/providers/Microsoft.Authorization/denyAssignments/43af7d0c-0bf8-407f-96c0-96a29d076431 DenyAssignmentName : Test deny assignment 1 Description : Test deny assignment for PS cmdlets Actions : {foo/*} @@ -312,7 +312,7 @@ Principals : { ExcludePrincipals : {} IsSystemProtected : True -Id : 94e3d9da-3700-4113-aab4-15f6c173d794 +Id : /subscriptions/4004a9fd-d58e-48dc-aeb2-4a4aec58606f/resourceGroups/testRG/providers/Microsoft.Web/sites/site1/providers/Microsoft.Authorization/denyAssignments/594e3d9da-3700-4113-aab4-15f6c173d794 DenyAssignmentName : Test deny assignment 2 Description : Test deny assignment for PS cmdlets Actions : {foo/*} @@ -383,7 +383,7 @@ Accept wildcard characters: False ``` ### -Id -Deny assignment id. +Deny assignment fully qualified ID or GUID. When Id is provided as a GUID, will take current subscription as default scope. ```yaml Type: System.Guid diff --git a/src/Resources/Resources/help/New-AzADAppCredential.md b/src/Resources/Resources/help/New-AzADAppCredential.md deleted file mode 100644 index 5749eed4667d..000000000000 --- a/src/Resources/Resources/help/New-AzADAppCredential.md +++ /dev/null @@ -1,342 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: 98836BC0-AB4F-4F24-88BE-E7DD350B71E8 -online version: https://docs.microsoft.com/powershell/module/az.resources/new-azadappcredential -schema: 2.0.0 ---- - -# New-AzADAppCredential - -## SYNOPSIS -Adds a credential to an existing application. - -## SYNTAX - -### ApplicationObjectIdWithPasswordParameterSet (Default) -``` -New-AzADAppCredential -ObjectId -Password [-StartDate ] [-EndDate ] - [-CustomKeyIdentifier ] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] -``` - -### ApplicationObjectIdWithCertValueParameterSet -``` -New-AzADAppCredential -ObjectId -CertValue [-StartDate ] [-EndDate ] - [-CustomKeyIdentifier ] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] -``` - -### ApplicationIdWithCertValueParameterSet -``` -New-AzADAppCredential -ApplicationId -CertValue [-StartDate ] [-EndDate ] - [-CustomKeyIdentifier ] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] -``` - -### ApplicationIdWithPasswordParameterSet -``` -New-AzADAppCredential -ApplicationId -Password [-StartDate ] - [-EndDate ] [-CustomKeyIdentifier ] [-DefaultProfile ] [-WhatIf] - [-Confirm] [] -``` - -### DisplayNameWithPasswordParameterSet -``` -New-AzADAppCredential -DisplayName -Password [-StartDate ] - [-EndDate ] [-CustomKeyIdentifier ] [-DefaultProfile ] [-WhatIf] - [-Confirm] [] -``` - -### DisplayNameWithCertValueParameterSet -``` -New-AzADAppCredential -DisplayName -CertValue [-StartDate ] [-EndDate ] - [-CustomKeyIdentifier ] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] -``` - -### ApplicationObjectWithCertValueParameterSet -``` -New-AzADAppCredential -ApplicationObject -CertValue [-StartDate ] - [-EndDate ] [-CustomKeyIdentifier ] [-DefaultProfile ] [-WhatIf] - [-Confirm] [] -``` - -### ApplicationObjectWithPasswordParameterSet -``` -New-AzADAppCredential -ApplicationObject -Password [-StartDate ] - [-EndDate ] [-CustomKeyIdentifier ] [-DefaultProfile ] [-WhatIf] - [-Confirm] [] -``` - -## DESCRIPTION -The New-AzADAppCredential cmdlet can be used to add a new credential or to roll credentials for an application. -The application is identified by supplying either the application object id or application Id. - -## EXAMPLES - -### Example 1 - Create a new application credential using a password - -``` -PS C:\> $SecureStringPassword = ConvertTo-SecureString -String "password" -AsPlainText -Force -PS C:\> New-AzADAppCredential -ObjectId 1f89cf81-0146-4f4e-beae-2007d0668416 -Password $SecureStringPassword -``` - -A new password credential is added to the existing application with object id '1f89cf81-0146-4f4e-beae-2007d0668416'. - -### Example 2 - Create a new application credential using a certificate - -``` -PS C:\> $cer = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:\myapp.cer") -PS C:\> $binCert = $cer.GetRawCertData() -PS C:\> $credValue = [System.Convert]::ToBase64String($binCert) -PS C:\> New-AzADAppCredential -ApplicationId 4589cd6b-3d79-4bb4-93b8-a0b99f3bfc58 -CertValue $credValue -StartDate $cer.NotBefore -EndDate $cer.NotAfter -``` - -The supplied base64 encoded public X509 certificate ("myapp.cer") is added to the existing application with application id '4589cd6b-3d79-4bb4-93b8-a0b99f3bfc58'. - -### Example 3 - Create a new application credential using piping - -``` -PS C:\> $SecureStringPassword = ConvertTo-SecureString -String "password" -AsPlainText -Force -PS C:\> Get-AzADApplication -ObjectId 1f89cf81-0146-4f4e-beae-2007d0668416 | New-AzADAppCredential -Password $SecureStringPassword -``` - -Gets the application with object id '1f89cf81-0146-4f4e-beae-2007d0668416' and pipes that to the New-AzADAppCredential to create a new application credential for that application with the given password. - -## PARAMETERS - -### -ApplicationId -The application id of the application to add the credentials to. - -```yaml -Type: System.Guid -Parameter Sets: ApplicationIdWithCertValueParameterSet, ApplicationIdWithPasswordParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ApplicationObject -The application object to add the credentials to. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADApplication -Parameter Sets: ApplicationObjectWithCertValueParameterSet, ApplicationObjectWithPasswordParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -CertValue -The value of the "asymmetric" credential type. It represents the base 64 encoded certificate. - -```yaml -Type: System.String -Parameter Sets: ApplicationObjectIdWithCertValueParameterSet, ApplicationIdWithCertValueParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.String -Parameter Sets: DisplayNameWithCertValueParameterSet, ApplicationObjectWithCertValueParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -CustomKeyIdentifier -Custom Key Identifier - -```yaml -Type: System.String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name of the application. - -```yaml -Type: System.String -Parameter Sets: DisplayNameWithPasswordParameterSet, DisplayNameWithCertValueParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -EndDate -The effective end date of the credential usage. The default end date value is one year from today. For an "asymmetric" type credential, this must be set to on or before the date that the X509 certificate is valid. - -```yaml -Type: System.DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the application to add the credentials to. - -```yaml -Type: System.String -Parameter Sets: ApplicationObjectIdWithPasswordParameterSet, ApplicationObjectIdWithCertValueParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Password -The password to be associated with the application. - -```yaml -Type: System.Security.SecureString -Parameter Sets: ApplicationObjectIdWithPasswordParameterSet, ApplicationIdWithPasswordParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.Security.SecureString -Parameter Sets: DisplayNameWithPasswordParameterSet, ApplicationObjectWithPasswordParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -StartDate -The effective start date of the credential usage. The default start date value is today. For an "asymmetric" type credential, this must be set to on or after the date that the X509 certificate is valid from. - -```yaml -Type: System.DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: cf - -Required: False -Position: Named -Default value: False -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -WhatIf -Shows what would happen if the cmdlet runs. -The cmdlet is not run. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: wi - -Required: False -Position: Named -Default value: False -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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### System.Guid - -### Microsoft.Azure.Commands.ActiveDirectory.PSADApplication - -### System.Security.SecureString - -### System.DateTime - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADCredential - -## NOTES - -## RELATED LINKS - -[Get-AzADAppCredential](./Get-AzADAppCredential.md) - -[Remove-AzADAppCredential](./Remove-AzADAppCredential.md) - -[Get-AzADApplication](./Get-AzADApplication.md) - diff --git a/src/Resources/Resources/help/New-AzADApplication.md b/src/Resources/Resources/help/New-AzADApplication.md deleted file mode 100644 index 4b691b859f9d..000000000000 --- a/src/Resources/Resources/help/New-AzADApplication.md +++ /dev/null @@ -1,337 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: F58FD77E-2946-44B1-B410-6E983FC20E21 -online version: https://docs.microsoft.com/powershell/module/az.resources/new-azadapplication -schema: 2.0.0 ---- - -# New-AzADApplication - -## SYNOPSIS -Creates a new azure active directory application. - -## SYNTAX - -### ApplicationWithoutCredentialParameterSet (Default) -``` -New-AzADApplication -DisplayName [-IdentifierUri ] [-HomePage ] - [-ReplyUrls ] [-AvailableToOtherTenants ] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### ApplicationWithPasswordPlainParameterSet -``` -New-AzADApplication -DisplayName [-IdentifierUri ] [-HomePage ] - [-ReplyUrls ] [-AvailableToOtherTenants ] -Password [-StartDate ] - [-EndDate ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationWithPasswordCredentialParameterSet -``` -New-AzADApplication -DisplayName [-IdentifierUri ] [-HomePage ] - [-ReplyUrls ] [-AvailableToOtherTenants ] -PasswordCredentials - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationWithKeyPlainParameterSet -``` -New-AzADApplication -DisplayName [-IdentifierUri ] [-HomePage ] - [-ReplyUrls ] [-AvailableToOtherTenants ] -CertValue [-StartDate ] - [-EndDate ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationWithKeyCredentialParameterSet -``` -New-AzADApplication -DisplayName [-IdentifierUri ] [-HomePage ] - [-ReplyUrls ] [-AvailableToOtherTenants ] -KeyCredentials - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Creates a new azure active directory application. Below are the permissions needed to create an application: - -- Azure Active Directory Graph - - Application.ReadWrite.OwnedBy -- Microsoft Graph - - Directory.AccessAsUser.All - - Directory.ReadWrite.All - -## EXAMPLES - -### Example 1: Create new AAD application. - -```powershell -PS C:\> New-AzADApplication -DisplayName "NewApplication" -HomePage "http://www.microsoft.com" -IdentifierUris "http://NewApplication" -``` - -Creates a new azure active directory application without any credentials. - -### Example 2: Create new AAD application with password. - -```powershell -PS C:\> $SecureStringPassword = ConvertTo-SecureString -String "password" -AsPlainText -Force -PS C:\> New-AzADApplication -DisplayName "NewApplication" -HomePage "http://www.microsoft.com" -IdentifierUris "http: -//NewApplication" -Password $SecureStringPassword -``` - -Creates a new azure active directory application and associates password credentials with it. - -## PARAMETERS - -### -AvailableToOtherTenants -The value specifying whether the application is a single tenant or a multi-tenant. - -```yaml -Type: System.Boolean -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -CertValue -The value of the "asymmetric" credential type. -It represents the base 64 encoded certificate. - -```yaml -Type: System.String -Parameter Sets: ApplicationWithKeyPlainParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -Display name of the new application. - -```yaml -Type: System.String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -EndDate -The effective end date of the credential usage. -The default end date value is one year from today. -For an "asymmetric" type credential, this must be set to on or before the date that the X509 certificate is valid. - -```yaml -Type: System.DateTime -Parameter Sets: ApplicationWithPasswordPlainParameterSet, ApplicationWithKeyPlainParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -HomePage -The URL to the application homepage. - -```yaml -Type: System.String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -IdentifierUri -The URIs that identify the application. - -```yaml -Type: System.String[] -Parameter Sets: (All) -Aliases: IdentifierUris - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -KeyCredentials -The list of certificate credentials associated with the application. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADKeyCredential[] -Parameter Sets: ApplicationWithKeyCredentialParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Password -The password to be associated with the application. - -```yaml -Type: System.Security.SecureString -Parameter Sets: ApplicationWithPasswordPlainParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -PasswordCredentials -The list of password credentials associated with the application. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential[] -Parameter Sets: ApplicationWithPasswordCredentialParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ReplyUrls -The application reply urls. - -```yaml -Type: System.String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -StartDate -The effective start date of the credential usage. -The default start date value is today. -For an "asymmetric" type credential, this must be set to on or after the date that the X509 certificate is valid from. - -```yaml -Type: System.DateTime -Parameter Sets: ApplicationWithPasswordPlainParameterSet, ApplicationWithKeyPlainParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### System.String[] - -### System.Boolean - -### Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential[] - -### Microsoft.Azure.Commands.ActiveDirectory.PSADKeyCredential[] - -### System.Security.SecureString - -### System.DateTime - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADApplication - -## NOTES -Keywords: azure, azurerm, arm, resource, management, manager, resource, group, template, deployment - -## RELATED LINKS - -[Remove-AzADApplication](./Remove-AzADApplication.md) - -[Get-AzADApplication](./Get-AzADApplication.md) - -[New-AzADServicePrincipal](./New-AzADServicePrincipal.md) - -[Get-AzADAppCredential](./Get-AzADAppCredential.md) - -[New-AzADAppCredential](./New-AzADAppCredential.md) - -[Remove-AzADAppCredential](./Remove-AzADAppCredential.md) - diff --git a/src/Resources/Resources/help/New-AzADGroup.md b/src/Resources/Resources/help/New-AzADGroup.md deleted file mode 100644 index a146f48cc00c..000000000000 --- a/src/Resources/Resources/help/New-AzADGroup.md +++ /dev/null @@ -1,145 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -online version: https://docs.microsoft.com/powershell/module/az.resources/new-azadgroup -schema: 2.0.0 ---- - -# New-AzADGroup - -## SYNOPSIS -Creates a new active directory group. - -## SYNTAX - -``` -New-AzADGroup -DisplayName -MailNickname [-Description ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Creates a new active directory group.Below are the permissions needed: - -- Azure Active Directory Graph - - Directory.ReadWrite.All -- Microsoft Graph - - Directory.ReadWrite.All - - PrivilegedAccess.ReadWrite.AzureADGroup - -## EXAMPLES - -### Example 1: Create a new AD group - -```powershell -PS C:\> New-AzADGroup -DisplayName "MyGroupDisplayName" -MailNickname "MyGroupNick" -``` - -Creates a new AD group with the name "MyGroupDisplayName" and the mail nickname "MyGroupNick". - -## PARAMETERS - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with Azure. - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Description -The description for the group. - -```yaml -Type: System.String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -DisplayName -The display name for the group. - -```yaml -Type: System.String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -MailNickname -The mail nickname for the group. Cannot contain the @ sign. - -```yaml -Type: System.String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADGroup - -## NOTES - -## RELATED LINKS diff --git a/src/Resources/Resources/help/New-AzADServicePrincipal.md b/src/Resources/Resources/help/New-AzADServicePrincipal.md deleted file mode 100644 index a2b8d5c1c45e..000000000000 --- a/src/Resources/Resources/help/New-AzADServicePrincipal.md +++ /dev/null @@ -1,644 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: D602F910-B26F-473D-B5B6-C7BDFB0A14CB -online version: https://docs.microsoft.com/powershell/module/az.resources/new-azadserviceprincipal -schema: 2.0.0 ---- - -# New-AzADServicePrincipal - -## SYNOPSIS -Creates a new Azure active directory service principal. - -## SYNTAX - -### SimpleParameterSet (Default) -``` -New-AzADServicePrincipal [-ApplicationId ] [-DisplayName ] [-StartDate ] - [-EndDate ] [-Scope ] [-Role ] [-SkipAssignment] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationWithoutCredentialParameterSet -``` -New-AzADServicePrincipal -ApplicationId [-DefaultProfile ] [-WhatIf] [-Confirm] - [] -``` - -### ApplicationWithPasswordPlainParameterSet -``` -New-AzADServicePrincipal -ApplicationId [-StartDate ] [-EndDate ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationWithPasswordCredentialParameterSet -``` -New-AzADServicePrincipal -ApplicationId -PasswordCredential - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationWithKeyPlainParameterSet -``` -New-AzADServicePrincipal -ApplicationId -CertValue [-StartDate ] - [-EndDate ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationWithKeyCredentialParameterSet -``` -New-AzADServicePrincipal -ApplicationId -KeyCredential - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### DisplayNameWithoutCredentialParameterSet -``` -New-AzADServicePrincipal -DisplayName [-DefaultProfile ] [-WhatIf] [-Confirm] - [] -``` - -### DisplayNameWithPasswordPlainParameterSet -``` -New-AzADServicePrincipal -DisplayName [-StartDate ] [-EndDate ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### DisplayNameWithPasswordCredentialParameterSet -``` -New-AzADServicePrincipal -DisplayName -PasswordCredential - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### DisplayNameWithKeyPlainParameterSet -``` -New-AzADServicePrincipal -DisplayName -CertValue [-StartDate ] - [-EndDate ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### DisplayNameWithKeyCredentialParameterSet -``` -New-AzADServicePrincipal -DisplayName -KeyCredential - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationObjectWithPasswordPlainParameterSet -``` -New-AzADServicePrincipal -ApplicationObject [-StartDate ] [-EndDate ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationObjectWithPasswordCredentialParameterSet -``` -New-AzADServicePrincipal -ApplicationObject -PasswordCredential - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationObjectWithKeyPlainParameterSet -``` -New-AzADServicePrincipal -ApplicationObject -CertValue [-StartDate ] - [-EndDate ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationObjectWithKeyCredentialParameterSet -``` -New-AzADServicePrincipal -ApplicationObject -KeyCredential - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION - -Creates a new Azure active directory service principal. The default parameter set uses default -values for parameters if they are not provided. For more information on default values, see the -description for each parameter. This cmdlet has the ability to assign a role to the service -principal with the **Role** and **Scope** parameters. If both are omitted, the contributor role is -assigned to the service principal. The default values for the **Role** and **Scope** parameters are -**Contributor** for the current subscription. The cmdlet creates an application and sets its -properties if an ApplicationId is not provided. To update the application-specific parameters, use -the [Update-AzADApplication](./update-azadapplication.md) cmdlet. - -> [!WARNING] -> When you create a service principal using the **New-AzADServicePrincipal** command, the output includes credentials that you must protect. As an alternative, consider using [managed identities](/azure/active-directory/managed-identities-azure-resources/overview) to avoid the need to use credentials. -> -> By default, **New-AzADServicePrincipal** assigns the [Contributor](/azure/role-based-access-control/built-in-roles#contributor) role to the service principal at the subscription scope. To reduce your risk of a compromised service principal, assign a more specific role and narrow the scope to a resource or resource group. See [Steps to add a role assignment](/azure/role-based-access-control/role-assignments-steps) for more information. - -## EXAMPLES - -### Example 1: Simple AD service principal creation - -The following example creates an AD service principal using default values for parameters not -specified. Since an application ID is not provided, an application is created for the service -principal. Since no values are provided for **Role** or **Scope**, the created service principal is -assigned the **contributor** role for the current subscription. - -```powershell -New-AzADServicePrincipal -``` - -```Output -Secret : System.Security.SecureString -ServicePrincipalNames : {00000000-0000-0000-0000-000000000000} -ApplicationId : 00000000-0000-0000-0000-000000000000 -DisplayName : azure-powershell-05-22-2018-18-23-43 -Id : 00000000-0000-0000-0000-000000000000 -Type : ServicePrincipal - -WARNING: Assigning role 'Contributor' over scope '/subscriptions/00000000-0000-0000-0000-000000000000' to the new service principal. -``` - -### Example 2: Simple AD service principal creation with a specified role and default scope - -The following example creates an AD service principal using the default values for parameters not -specified. Since the application ID is not provided, an application is created for the service -principal. The service principal is created with **Reader** permissions for the current subscription -since no value is provided for the **Scope** parameter. - -```powershell -New-AzADServicePrincipal -Role Reader -``` - -```Output -Secret : System.Security.SecureString -ServicePrincipalNames : {00000000-0000-0000-0000-000000000000} -ApplicationId : 00000000-0000-0000-0000-000000000000 -DisplayName : azure-powershell-05-22-2018-18-23-43 -Id : 00000000-0000-0000-0000-000000000000 -Type : ServicePrincipal - -WARNING: Assigning role 'Reader' over scope '/subscriptions/00000000-0000-0000-0000-000000000000' to the new service principal. -``` - -### Example 3: Simple AD service principal creation with a specified scope and default role - -The following example creates an AD service principal using the default values for parameters not -specified. Since the application ID is not provided, an application is created for the service -principal. The service principal is created with **Contributor** permissions for the provided -resource group scope since no value is provided for the **Role** parameter. - -```powershell -New-AzADServicePrincipal -Scope /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup -``` - -```Output -Secret : System.Security.SecureString -ServicePrincipalNames : {00000000-0000-0000-0000-000000000000} -ApplicationId : 00000000-0000-0000-0000-000000000000 -DisplayName : azure-powershell-05-22-2018-18-23-43 -Id : 00000000-0000-0000-0000-000000000000 -Type : ServicePrincipal - -WARNING: Assigning role 'Contributor' over scope '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup' to the new service principal. -``` - -### Example 4: Simple AD service principal creation with a specified scope and role - -The following example creates an AD service principal using the default values for parameters not -specified. Since the application ID is not provided, an application is created for the service -principal. The service principal is created with **Reader** permissions for the provided resource -group scope. - -```powershell -New-AzADServicePrincipal -Role Reader -Scope /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup -``` - -```Output -Secret : System.Security.SecureString -ServicePrincipalNames : {00000000-0000-0000-0000-000000000000} -ApplicationId : 00000000-0000-0000-0000-000000000000 -DisplayName : azure-powershell-05-22-2018-18-23-43 -Id : 00000000-0000-0000-0000-000000000000 -Type : ServicePrincipal - -WARNING: Assigning role 'Reader' over scope '/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup' to the new service principal. -``` - -### Example 5: Create a new AD service principal using application ID with role assignment - -The following example creates a new AD service principal for the application with application ID -'00000000-0000-0000-0000-000000000000'. Since no values are provided for **Role** or **Scope**, the -created service principal is assigned the **contributor** role for the current subscription. - -```powershell -New-AzADServicePrincipal -ApplicationId 00000000-0000-0000-0000-000000000000 -``` - -```Output -ServicePrincipalNames : {00000000-0000-0000-0000-000000000000, http://my-temp-app} -ApplicationId : 00000000-0000-0000-0000-000000000000 -DisplayName : my-temp-app -Id : 00000000-0000-0000-0000-000000000000 -Type : ServicePrincipal -``` - -### Example 6: Create a new AD service principal using piping - -The following example retrieves the application with object ID -'3ede3c26-b443-4e0b-9efc-b05e68338dc3' using the [Get-AzADApplication](./get-azadapplication.md) -cmdlet. The results are piped to the `New-AzADServicePrincipal` cmdlet to create a new AD service -principal for that application. - -```powershell -Get-AzADApplication -ObjectId 3ede3c26-b443-4e0b-9efc-b05e68338dc3 | New-AzADServicePrincipal -``` - -### Example 7: Create a new AD service principal using DisplayName and password credential - -The following example creates a new application with the name **ServicePrincipalName** and a -password of **StrongPassworld!23**. It creates the service principal based on the created -application. The start date and end date are added to the password credential. - -```powershell -$credentials = New-Object -TypeName Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential -Property @{ - StartDate=Get-Date; EndDate=Get-Date -Year 2024; Password='StrongPassworld!23'} -$sp = New-AzAdServicePrincipal -DisplayName ServicePrincipalName -PasswordCredential $credentials -``` - -```Output -ServicePrincipalNames : {00000000-0000-0000-0000-000000000000} -ApplicationId : 00000000-0000-0000-0000-000000000000c -ObjectType : ServicePrincipal -DisplayName : ServicePrincipalName -Id : 00000000-0000-0000-0000-000000000000 -Type : -``` - -### Example 8: Create a new AD service principal using DisplayName and plain key credential - -The following example creates a new application with the name **ServicePrincipalName** and a -certificate **$cert**. It creates the service principal based on the application created. The end -date is added to key credential. - -```powershell -$cert = 'public certificate as Base64 encoded string' -$sp = New-AzADServicePrincipal -DisplayName ServicePrincipalName -CertValue $cert -EndDate '2021-01-01' -``` - -```Output -ServicePrincipalNames : {00000000-0000-0000-0000-000000000000} -ApplicationId : 00000000-0000-0000-0000-000000000000 -ObjectType : ServicePrincipal -DisplayName : ServicePrincipalName -Id : 00000000-0000-0000-0000-000000000000 -Type : -``` - -## PARAMETERS - -### -ApplicationId - -The unique application ID for a service principal in a tenant. Once created this property cannot be -changed. If an application ID for an existing application is not specified, an application is -created. - -```yaml -Type: System.Guid -Parameter Sets: SimpleParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -```yaml -Type: System.Guid -Parameter Sets: ApplicationWithoutCredentialParameterSet, ApplicationWithPasswordPlainParameterSet, ApplicationWithPasswordCredentialParameterSet, ApplicationWithKeyPlainParameterSet, ApplicationWithKeyCredentialParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ApplicationObject - -The object representing the application for which the service principal is created. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADApplication -Parameter Sets: ApplicationObjectWithPasswordPlainParameterSet, ApplicationObjectWithPasswordCredentialParameterSet, ApplicationObjectWithKeyPlainParameterSet, ApplicationObjectWithKeyCredentialParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -CertValue - -The value of the asymmetric credential type. It represents the Base64 encoded certificate. - -```yaml -Type: System.String -Parameter Sets: ApplicationWithKeyPlainParameterSet, DisplayNameWithKeyPlainParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.String -Parameter Sets: ApplicationObjectWithKeyPlainParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -DefaultProfile - -The credentials, account, tenant, and subscription used for communication with Azure. - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName - -The friendly name of the service principal. If a display name is not provided, this value will -default to **azure-powershell-MM-dd-yyyy-HH-mm-ss** where the suffix is the time of application -creation. - -```yaml -Type: System.String -Parameter Sets: SimpleParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -```yaml -Type: System.String -Parameter Sets: DisplayNameWithoutCredentialParameterSet, DisplayNameWithPasswordPlainParameterSet, DisplayNameWithPasswordCredentialParameterSet, DisplayNameWithKeyPlainParameterSet, DisplayNameWithKeyCredentialParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -EndDate - -The effective end date of the credential usage. The default end date value is one year from today. -For an asymmetric type credential, this must be set to on or before the date that the X509 -certificate is valid. - -```yaml -Type: System.DateTime -Parameter Sets: SimpleParameterSet, ApplicationObjectWithPasswordPlainParameterSet, ApplicationObjectWithKeyPlainParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -```yaml -Type: System.DateTime -Parameter Sets: ApplicationWithPasswordPlainParameterSet, ApplicationWithKeyPlainParameterSet, DisplayNameWithPasswordPlainParameterSet, DisplayNameWithKeyPlainParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -KeyCredential - -The collection of key credentials associated with the application. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADKeyCredential[] -Parameter Sets: ApplicationWithKeyCredentialParameterSet, DisplayNameWithKeyCredentialParameterSet -Aliases: KeyCredentials - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADKeyCredential[] -Parameter Sets: ApplicationObjectWithKeyCredentialParameterSet -Aliases: KeyCredentials - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -PasswordCredential - -The collection of password credentials associated with the application. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential[] -Parameter Sets: ApplicationWithPasswordCredentialParameterSet, DisplayNameWithPasswordCredentialParameterSet -Aliases: PasswordCredentials - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential[] -Parameter Sets: ApplicationObjectWithPasswordCredentialParameterSet -Aliases: PasswordCredentials - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Role - -The role that the service principal has over the scope. If no value is provided, **Role** defaults -to the **Contributor** role. - -```yaml -Type: System.String -Parameter Sets: SimpleParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Scope - -The scope that the service principal has permissions for. If no value is provided, **Scope** -defaults to the current subscription. - -```yaml -Type: System.String -Parameter Sets: SimpleParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -SkipAssignment - -If set, skip creating the default role assignment for the service principal. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: SimpleParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -StartDate - -The effective start date of the credential usage. The default start date value is today. For an -asymmetric type credential, this must be set to on or after the date that the X509 certificate is -valid from. - -```yaml -Type: System.DateTime -Parameter Sets: SimpleParameterSet, ApplicationObjectWithPasswordPlainParameterSet, ApplicationObjectWithKeyPlainParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -```yaml -Type: System.DateTime -Parameter Sets: ApplicationWithPasswordPlainParameterSet, ApplicationWithKeyPlainParameterSet, DisplayNameWithPasswordPlainParameterSet, DisplayNameWithKeyPlainParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Confirm - -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.Guid - -### System.String - -### Microsoft.Azure.Commands.ActiveDirectory.PSADApplication - -### Microsoft.Azure.Commands.ActiveDirectory.PSADPasswordCredential[] - -### Microsoft.Azure.Commands.ActiveDirectory.PSADKeyCredential[] - -### System.DateTime - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal - -### Microsoft.Azure.Commands.Resources.Models.Authorization.PSADServicePrincipalWrapper - -## NOTES - -Keywords: azure, azurerm, arm, resource, management, manager, resource, group, template, deployment - -## RELATED LINKS - -[Remove-AzADServicePrincipal](./Remove-AzADServicePrincipal.md) - -[Get-AzADServicePrincipal](./Get-AzADServicePrincipal.md) - -[New-AzADApplication](./New-AzADApplication.md) - -[Remove-AzADApplication](./Remove-AzADApplication.md) - -[Get-AzADSpCredential](./Get-AzADSpCredential.md) - -[New-AzADSpCredential](./New-AzADSpCredential.md) - -[Remove-AzADSpCredential](./Remove-AzADSpCredential.md) \ No newline at end of file diff --git a/src/Resources/Resources/help/New-AzADSpCredential.md b/src/Resources/Resources/help/New-AzADSpCredential.md deleted file mode 100644 index 1498cfd2f2c6..000000000000 --- a/src/Resources/Resources/help/New-AzADSpCredential.md +++ /dev/null @@ -1,281 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: 063BAA79-484D-48CF-9170-3808813752BD -online version: https://docs.microsoft.com/powershell/module/az.resources/new-azadspcredential -schema: 2.0.0 ---- - -# New-AzADSpCredential - -## SYNOPSIS -Adds a credential to an existing service principal. - -## SYNTAX - -### SpObjectIdWithPasswordParameterSet (Default) -``` -New-AzADSpCredential -ObjectId [-StartDate ] [-EndDate ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### SpObjectIdWithCertValueParameterSet -``` -New-AzADSpCredential -ObjectId -CertValue [-StartDate ] [-EndDate ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### SPNWithCertValueParameterSet -``` -New-AzADSpCredential -ServicePrincipalName -CertValue [-StartDate ] - [-EndDate ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### SPNWithPasswordParameterSet -``` -New-AzADSpCredential -ServicePrincipalName [-StartDate ] [-EndDate ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ServicePrincipalObjectWithCertValueParameterSet -``` -New-AzADSpCredential -ServicePrincipalObject -CertValue [-StartDate ] - [-EndDate ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ServicePrincipalObjectWithPasswordParameterSet -``` -New-AzADSpCredential -ServicePrincipalObject [-StartDate ] - [-EndDate ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -The New-AzADSpCredential cmdlet can be used to add a new credential or to roll credentials for a service principal. -The service principal is identified by supplying either the object id or service principal name. - -## EXAMPLES - -### Example 1: Create a new service principal credential using a generated password - -```powershell -PS C:\> New-AzADSpCredential -ObjectId 1f99cf81-0146-4f4e-beae-2007d0668476 - -Secret : System.Security.SecureString -StartDate : 11/12/2018 9:36:05 PM -EndDate : 11/12/2019 9:36:05 PM -KeyId : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -Type : Password -``` - -A new password credential is added to the existing service principal with object id '1f99cf81-0146-4f4e-beae-2007d0668476'. - -### Example 2: Create a new service principal credential using a certificate - -```powershell -PS C:\> $cer = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -PS C:\> $cer.Import("C:\myapp.cer") -PS C:\> $binCert = $cer.GetRawCertData() -PS C:\> $credValue = [System.Convert]::ToBase64String($binCert) -PS C:\> New-AzADSpCredential -ServicePrincipalName "http://test123" -CertValue $credValue -StartDate $cer.NotBefore -EndDate $cer.NotAfter -``` - -The supplied base64 encoded public X509 certificate ("myapp.cer") is added to the existing service principal using its SPN. - -### Example 3: Create a new service principal credential using piping - -```powershell -PS C:\> Get-AzADServicePrincipal -ObjectId 1f99cf81-0146-4f4e-beae-2007d0668476 | New-AzADSpCredential - -Secret : System.Security.SecureString -StartDate : 11/12/2018 9:36:05 PM -EndDate : 11/12/2019 9:36:05 PM -KeyId : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -Type : Password -``` - -Gets the service principal with object id '1f99cf81-0146-4f4e-beae-2007d0668476' and pipes that to the New-AzADSpCredential to create a new service principal credential for that service principal with a generated password. - -## PARAMETERS - -### -CertValue -The value of the "asymmetric" credential type. -It represents the base 64 encoded certificate. - -```yaml -Type: System.String -Parameter Sets: SpObjectIdWithCertValueParameterSet, SPNWithCertValueParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.String -Parameter Sets: ServicePrincipalObjectWithCertValueParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -EndDate -The effective end date of the credential usage. -The default end date value is one year from today. -For an "asymmetric" type credential, this must be set to on or before the date that the X509 certificate is valid. - -```yaml -Type: System.DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the service principal to add the credentials to. - -```yaml -Type: System.String -Parameter Sets: SpObjectIdWithPasswordParameterSet, SpObjectIdWithCertValueParameterSet -Aliases: ServicePrincipalObjectId - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ServicePrincipalName -The name (SPN) of the service principal to add the credentials to. - -```yaml -Type: System.String -Parameter Sets: SPNWithCertValueParameterSet, SPNWithPasswordParameterSet -Aliases: SPN - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ServicePrincipalObject -The service principal object to add the credentials to. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal -Parameter Sets: ServicePrincipalObjectWithCertValueParameterSet, ServicePrincipalObjectWithPasswordParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -StartDate -The effective start date of the credential usage. -The default start date value is today. -For an "asymmetric" type credential, this must be set to on or after the date that the X509 certificate is valid from. - -```yaml -Type: System.DateTime -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal - -### System.DateTime - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADCredential - -### Microsoft.Azure.Commands.Resources.Models.Authorization.PSADCredentialWrapper - -## NOTES - -## RELATED LINKS - -[Get-AzADSpCredential](./Get-AzADSpCredential.md) - -[Remove-AzADSpCredential](./Remove-AzADSpCredential.md) - -[Get-AzADServicePrincipal](./Get-AzADServicePrincipal.md) - - - diff --git a/src/Resources/Resources/help/New-AzADUser.md b/src/Resources/Resources/help/New-AzADUser.md deleted file mode 100644 index e6ccf94f7d34..000000000000 --- a/src/Resources/Resources/help/New-AzADUser.md +++ /dev/null @@ -1,202 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: 86D8965D-D999-48A4-A4EE-9E054E5486EE -online version: https://docs.microsoft.com/powershell/module/az.resources/new-azaduser -schema: 2.0.0 ---- - -# New-AzADUser - -## SYNOPSIS -Creates a new active directory user. - -## SYNTAX - -``` -New-AzADUser -DisplayName -UserPrincipalName -Password [-ImmutableId ] - -MailNickname [-ForceChangePasswordNextLogin] [-DefaultProfile ] [-WhatIf] - [-Confirm] [] -``` - -## DESCRIPTION -Creates a new active directory user (work/school account also popularly known as org-id). -For more information: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#CreateUser - -## EXAMPLES - -### Example 1: Create a new AD user -```powershell -PS C:\> $SecureStringPassword = ConvertTo-SecureString -String "password" -AsPlainText -Force -PS C:\> New-AzADUser -DisplayName "MyDisplayName" -UserPrincipalName "myemail@domain.com" -Password $SecureStringPassword -MailNickname "MyMailNickName" -``` - -Creates a new AD user with the name "MyDisplayName" and user principal name "myemail@domain.com" in a tenant. - -## PARAMETERS - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The name to display in the address book for the user. -example 'Alex Wu'. - -```yaml -Type: System.String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ForceChangePasswordNextLogin -It must be specified if the user must change the password on the next successful login (true). -Default behavior is (false) to not change the password on the next successful login. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ImmutableId -It needs to be specified only if you are using a federated domain for the user's user principal name (upn) property. - -```yaml -Type: System.String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -MailNickname -The mail alias for the user. - -```yaml -Type: System.String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Password -Password for the user. -It must meet the tenant's password complexity requirements. -It is recommended to set a strong password. - -```yaml -Type: System.Security.SecureString -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -UserPrincipalName -The user principal name. -Example-'someuser@contoso.com'. - -```yaml -Type: System.String -Parameter Sets: (All) -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### System.Security.SecureString - -### System.Management.Automation.SwitchParameter - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADUser - -## NOTES - -## RELATED LINKS - -[Get-AzADUser](./Get-AzADUser.md) - -[Update-AzADUser](./Update-AzADUser.md) - -[Remove-AzADUser](./Remove-AzADUser.md) diff --git a/src/Resources/Resources/help/Remove-AzADAppCredential.md b/src/Resources/Resources/help/Remove-AzADAppCredential.md deleted file mode 100644 index 7976b896ac4e..000000000000 --- a/src/Resources/Resources/help/Remove-AzADAppCredential.md +++ /dev/null @@ -1,260 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: C61FA834-BEBE-4DBF-888F-C6CB8CC95390 -online version: https://docs.microsoft.com/powershell/module/az.resources/remove-azadappcredential -schema: 2.0.0 ---- - -# Remove-AzADAppCredential - -## SYNOPSIS -Removes a credential from an application. - -## SYNTAX - -### ApplicationObjectIdWithKeyIdParameterSet (Default) -``` -Remove-AzADAppCredential -ObjectId [-KeyId ] [-PassThru] [-Force] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationIdWithKeyIdParameterSet -``` -Remove-AzADAppCredential -ApplicationId [-KeyId ] [-PassThru] [-Force] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationDisplayNameParameterSet -``` -Remove-AzADAppCredential -DisplayName [-PassThru] [-Force] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### ApplicationObjectWithKeyIdParameterSet -``` -Remove-AzADAppCredential [-KeyId ] -ApplicationObject [-PassThru] [-Force] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -The Remove-AzADAppCredential cmdlet can be used to remove a credential key from an application in the case of a compromise or as part of credential key rollover expiration. -The application is identified by supplying either the object ID or AppId. -The credential to be removed is identified by its key ID. - -## EXAMPLES - -### Example 1: Remove a specific credential from an application - -```powershell -PS C:\> Remove-AzADAppCredential -ObjectId 7663d3fb-6f86-4352-9e6d-cf9d50d5ee82 -KeyId 9044423a-60a3-45ac-9ab1-09534157ebb -``` - -Removes the credential with key id '9044423a-60a3-45ac-9ab1-09534157ebb' from the application with object id '7663d3fb-6f86-4352-9e6d-cf9d50d5ee82'. - -### Example 2: Remove all credentials from an application - -```powershell -PS C:\> Remove-AzADAppCredential -ApplicationId 4589cd6b-3d79-4bb4-93b8-a0b99f3bfc58 -``` - -Removes all credentials from the application with application id '4589cd6b-3d79-4bb4-93b8-a0b99f3bfc58'. - -### Example 3: Remove all credentials using piping - -```powershell -PS C:\> Get-AzADApplication -ObjectId 7663d3fb-6f86-4352-9e6d-cf9d50d5ee82 | Remove-AzADAppCredential -``` - -Gets the application with object id '7663d3fb-6f86-4352-9e6d-cf9d50d5ee82' and pipes that to the Remove-AzADAppCredential cmdlet and removes all credentials from that application. - -## PARAMETERS - -### -ApplicationId -The id of the application to remove the credentials from. - -```yaml -Type: System.Guid -Parameter Sets: ApplicationIdWithKeyIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ApplicationObject -The application object to remove the credentials from. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADApplication -Parameter Sets: ApplicationObjectWithKeyIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name of the application. - -```yaml -Type: System.String -Parameter Sets: ApplicationDisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Force -Switch to delete credential without a confirmation. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -KeyId -Specifies the credential key to be removed. -The key Ids for the application can be obtained using the Get-AzADAppCredential cmdlet. - -```yaml -Type: System.Guid -Parameter Sets: ApplicationObjectIdWithKeyIdParameterSet, ApplicationIdWithKeyIdParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.Guid -Parameter Sets: ApplicationObjectWithKeyIdParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the application to remove the credentials from. - -```yaml -Type: System.String -Parameter Sets: ApplicationObjectIdWithKeyIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -PassThru -Specifying this will return true if the command was successful. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### System.Guid - -### Microsoft.Azure.Commands.ActiveDirectory.PSADApplication - -## OUTPUTS - -### System.Boolean - -## NOTES - -## RELATED LINKS - -[Get-AzADAppCredential](./Get-AzADAppCredential.md) - -[New-AzADAppCredential](./New-AzADAppCredential.md) - -[Get-AzADApplication](./Get-AzADApplication.md) diff --git a/src/Resources/Resources/help/Remove-AzADApplication.md b/src/Resources/Resources/help/Remove-AzADApplication.md deleted file mode 100644 index 635475734ba6..000000000000 --- a/src/Resources/Resources/help/Remove-AzADApplication.md +++ /dev/null @@ -1,234 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: C791C593-F7D5-4961-97F9-E4909813FFE7 -online version: https://docs.microsoft.com/powershell/module/az.resources/remove-azadapplication -schema: 2.0.0 ---- - -# Remove-AzADApplication - -## SYNOPSIS -Deletes the azure active directory application. - -## SYNTAX - -### ObjectIdParameterSet (Default) -``` -Remove-AzADApplication -ObjectId [-PassThru] [-Force] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### ApplicationIdParameterSet -``` -Remove-AzADApplication -ApplicationId [-PassThru] [-Force] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### ApplicationDisplayNameParameterSet -``` -Remove-AzADApplication -DisplayName [-PassThru] [-Force] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### InputObjectParameterSet -``` -Remove-AzADApplication -InputObject [-PassThru] [-Force] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Deletes the azure active directory application. - -## EXAMPLES - -### Example 1: Remove application by object id - -```powershell -PS C:\> Remove-AzADApplication -ObjectId b4cd1619-80b3-4cfb-9f8f-9f2333425738 -``` - -Removes the application with object id 'b4cd1619-80b3-4cfb-9f8f-9f2333425738' from the tenant. - -### Example 2: Remove application by application id - -```powershell -PS C:\> Remove-AzADApplication -ApplicationId f9c5ea4f-28f0-401a-a491-491a037fa346 -``` - -Removes the application with application id 'f9c5ea4f-28f0-401a-a491-491a037fa346' from the tenant. - -### Example 3: Remove application by piping - -```powershell -PS C:\> Get-AzADApplication -ObjectId b4cd1619-80b3-4cfb-9f8f-9f2333425738 | Remove-AzADApplication -``` - -Gets the application with object id 'b4cd1619-80b3-4cfb-9f8f-9f2333425738' and pipes that to the Remove-AzADApplication cmdlet to remove the application from the tenant. - -## PARAMETERS - -### -ApplicationId -The application id of the application to remove. - -```yaml -Type: System.Guid -Parameter Sets: ApplicationIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name of the application. - -```yaml -Type: System.String -Parameter Sets: ApplicationDisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Force -Switch to delete an application without a confirmation. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The object representing the application to remove. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADApplication -Parameter Sets: InputObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the application to delete. - -```yaml -Type: System.String -Parameter Sets: ObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -PassThru -Specifying this will return true if the command was successful. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### System.Guid - -### Microsoft.Azure.Commands.ActiveDirectory.PSADApplication - -## OUTPUTS - -### System.Boolean - -## NOTES -Keywords: azure, azurerm, arm, resource, management, manager, resource, group, template, deployment - -## RELATED LINKS - -[New-AzADApplication](./New-AzADApplication.md) - -[Get-AzADApplication](./Get-AzADApplication.md) - -[Update-AzADApplication](./Update-AzADApplication.md) - -[Remove-AzADAppCredential](./Remove-AzADAppCredential.md) - diff --git a/src/Resources/Resources/help/Remove-AzADGroup.md b/src/Resources/Resources/help/Remove-AzADGroup.md deleted file mode 100644 index 9e14e57dca76..000000000000 --- a/src/Resources/Resources/help/Remove-AzADGroup.md +++ /dev/null @@ -1,201 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -online version: https://docs.microsoft.com/powershell/module/az.resources/remove-azadgroup -schema: 2.0.0 ---- - -# Remove-AzADGroup - -## SYNOPSIS -Deletes an active directory group. - -## SYNTAX - -### ObjectIdParameterSet (Default) -``` -Remove-AzADGroup -ObjectId [-PassThru] [-Force] [-DefaultProfile ] [-WhatIf] - [-Confirm] [] -``` - -### DisplayNameParameterSet -``` -Remove-AzADGroup -DisplayName [-PassThru] [-Force] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### InputObjectParameterSet -``` -Remove-AzADGroup -InputObject [-PassThru] [-Force] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Deletes an active directory group. - -## EXAMPLES - -### Example 1: Remove a group by object id - -```powershell -PS C:\> Remove-AzADGroup -ObjectId 85F89C90-780E-4AA6-9F4F-6F268D322EEE -``` - -Removes the group with object id '85F89C90-780E-4AA6-9F4F-6F268D322EEE' from the tenant. - -### Example 2: Remove a group by piping - -```powershell -PS C:\> Get-AzADGroup -ObjectId 85F89C90-780E-4AA6-9F4F-6F268D322EEE | Remove-AzADGroup -``` - -Gets the group with object id '85F89C90-780E-4AA6-9F4F-6F268D322EEE' and pipes that to Remove-AzADGroup to remove the group from the tenant. - -### Example 3 - -Deletes an active directory group. (autogenerated) - - -```powershell -Remove-AzADGroup -DisplayName MyNewDisplayName -``` - -## PARAMETERS - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with Azure. - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name of the group to be removed. - -```yaml -Type: System.String -Parameter Sets: DisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Force -If specified, doesn't ask for confirmation for deleting the group. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The object representation of the group to be removed. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADGroup -Parameter Sets: InputObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the group to be removed. - -```yaml -Type: System.String -Parameter Sets: ObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -PassThru -Specifying this will return true if the command was successful. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### Microsoft.Azure.Commands.ActiveDirectory.PSADGroup - -## OUTPUTS - -### System.Boolean - -## NOTES - -## RELATED LINKS \ No newline at end of file diff --git a/src/Resources/Resources/help/Remove-AzADGroupMember.md b/src/Resources/Resources/help/Remove-AzADGroupMember.md deleted file mode 100644 index 973d8fda2233..000000000000 --- a/src/Resources/Resources/help/Remove-AzADGroupMember.md +++ /dev/null @@ -1,238 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -online version: https://docs.microsoft.com/powershell/module/az.resources/remove-azadgroupmember -schema: 2.0.0 ---- - -# Remove-AzADGroupMember - -## SYNOPSIS -Removes a user from an AD group. - -## SYNTAX - -### ExplicitParameterSet (Default) -``` -Remove-AzADGroupMember [-PassThru] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] -``` - -### MemberObjectIdWithGroupDisplayName -``` -Remove-AzADGroupMember -MemberObjectId -GroupDisplayName [-PassThru] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### MemberObjectIdWithGroupObject -``` -Remove-AzADGroupMember -MemberObjectId -GroupObject [-PassThru] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### MemberObjectIdWithGroupObjectId -``` -Remove-AzADGroupMember -MemberObjectId -GroupObjectId [-PassThru] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### MemberUPNWithGroupDisplayNameParameterSet -``` -Remove-AzADGroupMember -MemberUserPrincipalName -GroupDisplayName [-PassThru] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### MemberUPNWithGroupObjectParameterSet -``` -Remove-AzADGroupMember -MemberUserPrincipalName -GroupObject [-PassThru] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### MemberUPNWithGroupObjectIdParameterSet -``` -Remove-AzADGroupMember -MemberUserPrincipalName -GroupObjectId [-PassThru] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Removes a user from an AD group. - -## EXAMPLES - -### Example 1: Remove a user from a group by object id - -```powershell -PS C:\> Remove-AzADGroupMember -MemberObjectId D9076BBC-D62C-4105-9C78-A7F5BC4A3405 -GroupObjectId 85F89C90-780E-4AA6-9F4F-6F268D322EEE -``` - -Removes the user with object id 'D9076BBC-D62C-4105-9C78-A7F5BC4A3405' from the group with object id '85F89C90-780E-4AA6-9F4F-6F268D322EEE'. - -### Example 2: Remove a user from a group by piping - -```powershell -PS C:\> Get-AzADGroup -ObjectId 85F89C90-780E-4AA6-9F4F-6F268D322EEE | Remove-AzADGroupMember -MemberObjectId D9076BBC-D62C-4105-9C78-A7F5BC4A3405 -``` - -Gets the group with object id '85F89C90-780E-4AA6-9F4F-6F268D322EEE' and pipes it to the Remove-AzADGroupMember cmdlet to remove the user to that group. - -### Example 3 - -Removes a user from an AD group. (autogenerated) - - -```powershell -Remove-AzADGroupMember -GroupDisplayName 'MyGroupDisplayName' -MemberUserPrincipalName 'myemail@domain.com' -``` - -## PARAMETERS - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with Azure. - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -GroupDisplayName -The display name of the group to remove the member(s) from. - -```yaml -Type: System.String -Parameter Sets: MemberObjectIdWithGroupDisplayName, MemberUPNWithGroupDisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -GroupObject -The object representation of the group to remove the member from. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADGroup -Parameter Sets: MemberObjectIdWithGroupObject, MemberUPNWithGroupObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -GroupObjectId -The object id of the group to remove the member from. - -```yaml -Type: System.String -Parameter Sets: MemberObjectIdWithGroupObjectId, MemberUPNWithGroupObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -MemberObjectId -The object id of the member. - -```yaml -Type: System.String[] -Parameter Sets: MemberObjectIdWithGroupDisplayName, MemberObjectIdWithGroupObject, MemberObjectIdWithGroupObjectId -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -MemberUserPrincipalName -The UPN of the member(s) to remove. - -```yaml -Type: System.String[] -Parameter Sets: MemberUPNWithGroupDisplayNameParameterSet, MemberUPNWithGroupObjectParameterSet, MemberUPNWithGroupObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -PassThru -Specifying this will return true if the command was successful. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADGroup - -## OUTPUTS - -### System.Boolean - -## NOTES - -## RELATED LINKS diff --git a/src/Resources/Resources/help/Remove-AzADServicePrincipal.md b/src/Resources/Resources/help/Remove-AzADServicePrincipal.md deleted file mode 100644 index 9c5435eadc2b..000000000000 --- a/src/Resources/Resources/help/Remove-AzADServicePrincipal.md +++ /dev/null @@ -1,295 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: 0C8C07CA-6720-452F-A952-48C76EBF3BBD -online version: https://docs.microsoft.com/powershell/module/az.resources/remove-azadserviceprincipal -schema: 2.0.0 ---- - -# Remove-AzADServicePrincipal - -## SYNOPSIS -Deletes the azure active directory service principal. - -## SYNTAX - -### ObjectIdParameterSet (Default) -``` -Remove-AzADServicePrincipal -ObjectId [-PassThru] [-Force] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### ApplicationIdParameterSet -``` -Remove-AzADServicePrincipal -ApplicationId [-PassThru] [-Force] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### SPNParameterSet -``` -Remove-AzADServicePrincipal -ServicePrincipalName [-PassThru] [-Force] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### DisplayNameParameterSet -``` -Remove-AzADServicePrincipal -DisplayName [-PassThru] [-Force] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### InputObjectParameterSet -``` -Remove-AzADServicePrincipal -InputObject [-PassThru] [-Force] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationObjectParameterSet -``` -Remove-AzADServicePrincipal -ApplicationObject [-PassThru] [-Force] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Deletes the azure active directory service principal. - -## EXAMPLES - -### Example 1: Remove a service principal by object id - -```powershell -PS C:\> Remove-AzADServicePrincipal -ObjectId 61b5d8ea-fdc6-40a2-8d5b-ad447c678d45 -``` - -Removes the service principal with object id '61b5d8ea-fdc6-40a2-8d5b-ad447c678d45'. - -### Example 2: Remove a service principal by application id - -```powershell -PS C:\> Remove-AzADServicePrincipal -ApplicationId 9263469e-d328-4321-8646-3e3e75d20e76 -``` - -Removes the service principal with application id '9263469e-d328-4321-8646-3e3e75d20e76'. - -### Example 3: Remove a service principal by SPN - -```powershell -PS C:\> Remove-AzADServicePrincipal -ServicePrincipalName MyServicePrincipal -``` - -Remove the service principal with service principal name "MyServicePrincipal" - -### Example 4: Remove a service principal by piping - -```powershell -PS C:\> Get-AzADServicePrincipal -ObjectId 61b5d8ea-fdc6-40a2-8d5b-ad447c678d45 | Remove-AzADServicePrincipal -``` - -Gets the service principal with object id '61b5d8ea-fdc6-40a2-8d5b-ad447c678d45' and pipes that to the Remove-AzADServicePrincipal cmdlet to remove that service principal. - -### Example 5: Remove a service principal by piping an application - -```powershell -PS C:\> Get-AzApplication -ApplicationId 9263469e-d328-4321-8646-3e3e75d20e76 | Remove-AzADServicePrincipal -``` - -Gets the application with application id '9263469e-d328-4321-8646-3e3e75d20e76' and pipes that to the Remove-AzADServicePrincipal cmdlet to remove the service principal associated with that application. - -## PARAMETERS - -### -ApplicationId -The service principal application id. - -```yaml -Type: System.Guid -Parameter Sets: ApplicationIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ApplicationObject -The application object whose service principal is being removed. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADApplication -Parameter Sets: ApplicationObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name of the service principal. - -```yaml -Type: System.String -Parameter Sets: DisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Force -Switch to delete service principal without a confirmation. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The service principal object. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal -Parameter Sets: InputObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the service principal to delete. - -```yaml -Type: System.String -Parameter Sets: ObjectIdParameterSet -Aliases: PrincipalId, Id - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -PassThru -If specified, returns the deleted service principal. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ServicePrincipalName -The service principal name. - -```yaml -Type: System.String -Parameter Sets: SPNParameterSet -Aliases: SPN - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### System.Guid - -### Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal - -### Microsoft.Azure.Commands.ActiveDirectory.PSADApplication - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal - -## NOTES -Keywords: azure, azurerm, arm, resource, management, manager, resource, group, template, deployment - -## RELATED LINKS - -[New-AzADServicePrincipal](./New-AzADServicePrincipal.md) - -[Get-AzADServicePrincipal](./Get-AzADServicePrincipal.md) - -[Update-AzADServicePrincipal](./Update-AzADServicePrincipal.md) - -[Remove-AzADApplication](./Remove-AzADApplication.md) - -[Remove-AzADAppCredential](./Remove-AzADAppCredential.md) diff --git a/src/Resources/Resources/help/Remove-AzADSpCredential.md b/src/Resources/Resources/help/Remove-AzADSpCredential.md deleted file mode 100644 index 9b9a0054decd..000000000000 --- a/src/Resources/Resources/help/Remove-AzADSpCredential.md +++ /dev/null @@ -1,249 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: 04B1E3A6-6D52-46A3-8241-2CCDB5E71642 -online version: https://docs.microsoft.com/powershell/module/az.resources/remove-azadspcredential -schema: 2.0.0 ---- - -# Remove-AzADSpCredential - -## SYNOPSIS -Removes a credential from a service principal. - -## SYNTAX - -### ObjectIdWithKeyIdParameterSet (Default) -``` -Remove-AzADSpCredential -ObjectId [-KeyId ] [-PassThru] [-Force] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### SPNWithKeyIdParameterSet -``` -Remove-AzADSpCredential -ServicePrincipalName [-KeyId ] [-PassThru] [-Force] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### DisplayNameWithKeyIdParameterSet -``` -Remove-AzADSpCredential -DisplayName [-PassThru] [-Force] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### ServicePrincipalObjectParameterSet -``` -Remove-AzADSpCredential -ServicePrincipalObject [-KeyId ] [-PassThru] [-Force] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -The Remove-AzADSpCredential cmdlet can be used to remove a credential key from a service principal in the case of a compromise or as part of credential key rollover expiration. -The service principal is identified by supplying either the object ID or service principal name (SPN). -The credential to be removed is identified by its key ID if an individual credential is to be removed or with an 'All' switch to delete all credentials associated with the service principal. - -## EXAMPLES - -### Example 1: Remove a specific credential from a service principal - -```powershell -PS C:\> Remove-AzADSpCredential -ObjectId 7663d3fb-6f86-4352-9e6d-cf9d50d5ee82 -KeyId 9044423a-60a3-45ac-9ab1-09534157ebb -``` - -Removes the credential with key id '9044423a-60a3-45ac-9ab1-09534157ebb' from the service principal with object id '7663d3fb-6f86-4352-9e6d-cf9d50d5ee82'. - -### Example 2: Remove all credentials from a service principal - -```powershell -PS C:\> Remove-AzADSpCredential -ServicePrincipalName http://test123 -``` - -Removes all credentials from the service principal with the SPN "http://test123". - -### Example 3: Remove all credentials from a service principal using piping - -```powershell -PS C:\> Get-AzADServicePrincipal -ObjectId 7663d3fb-6f86-4352-9e6d-cf9d50d5ee82 | Remove-AzADSpCredential -``` - -Gets the service principal with object id '7663d3fb-6f86-4352-9e6d-cf9d50d5ee82' and pipes that to the Remove-AzADSpCredential cmdlet to remove all credentials from that service principal. - -## PARAMETERS - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name of the service principal. - -```yaml -Type: System.String -Parameter Sets: DisplayNameWithKeyIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Force -Switch to delete credential without a confirmation. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -KeyId -Specifies the credential key to be removed. -The key Ids for a service principal can be obtained using the Get-AzADSpCredential cmdlet. - -```yaml -Type: System.Guid -Parameter Sets: ObjectIdWithKeyIdParameterSet, SPNWithKeyIdParameterSet, ServicePrincipalObjectParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the service principal to remove the credentials from. - -```yaml -Type: System.String -Parameter Sets: ObjectIdWithKeyIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -PassThru -Specifying this will return true if the command was successful. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ServicePrincipalName -The name (SPN) of the service principal to remove the credentials from. - -```yaml -Type: System.String -Parameter Sets: SPNWithKeyIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ServicePrincipalObject -The service principal object to remove the credentials from. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal -Parameter Sets: ServicePrincipalObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal - -### System.Guid - -## OUTPUTS - -### System.Boolean - -## NOTES - -## RELATED LINKS - -[Get-AzADSpCredential](./Get-AzADSpCredential.md) - -[New-AzADSpCredential](./New-AzADSpCredential.md) - -[Get-AzADServicePrincipal](./Get-AzADServicePrincipal.md) - diff --git a/src/Resources/Resources/help/Remove-AzADUser.md b/src/Resources/Resources/help/Remove-AzADUser.md deleted file mode 100644 index fd454541a216..000000000000 --- a/src/Resources/Resources/help/Remove-AzADUser.md +++ /dev/null @@ -1,250 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -ms.assetid: 9F9B2691-BB3F-4644-BD95-6D74777D1E99 -online version: https://docs.microsoft.com/powershell/module/az.resources/remove-azaduser -schema: 2.0.0 ---- - -# Remove-AzADUser - -## SYNOPSIS -Deletes an active directory user. - -## SYNTAX - -### UPNOrObjectIdParameterSet (Default) -``` -Remove-AzADUser -UPNOrObjectId [-PassThru] [-Force] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### UPNParameterSet -``` -Remove-AzADUser -UserPrincipalName [-PassThru] [-Force] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### ObjectIdParameterSet -``` -Remove-AzADUser -ObjectId [-PassThru] [-Force] [-DefaultProfile ] [-WhatIf] - [-Confirm] [] -``` - -### DisplayNameParameterSet -``` -Remove-AzADUser -DisplayName [-PassThru] [-Force] [-DefaultProfile ] [-WhatIf] - [-Confirm] [] -``` - -### InputObjectParameterSet -``` -Remove-AzADUser -InputObject [-PassThru] [-Force] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Deletes an active directory user (work/school account also popularly known as org-id). - -## EXAMPLES - -### Example 1: Remove a user by user principal name - -```powershell -PS C:\> Remove-AzADUser -UserPrincipalName foo@domain.com -``` - -Removes the user with user principal name "foo@domain.com" from the tenant. - -### Example 2: Remove a user by object id - -```powershell -PS C:\> Remove-AzADUser -ObjectId 7a9582cf-88c4-4319-842b-7a5d60967a69 -``` - -Removes the user with object id '7a9582cf-88c4-4319-842b-7a5d60967a69' from the tenant. - -### Example 3: Remove a user by piping - -```powershell -PS C:\> Get-AzADUser -ObjectId 7a9582cf-88c4-4319-842b-7a5d60967a69 | Remove-AzADUser -``` - -Gets the user with object id '7a9582cf-88c4-4319-842b-7a5d60967a69' and pipes that to the Remove-AzADUser cmdlet to remove the user from the tenant. - -## PARAMETERS - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with azure - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name of the user to be deleted. - -```yaml -Type: System.String -Parameter Sets: DisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Force -If specified, doesn't ask for confirmation for deleting the user. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The user object to be deleted. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADUser -Parameter Sets: InputObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the user to be deleted. - -```yaml -Type: System.String -Parameter Sets: ObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -PassThru -Specifying this will return true if the command was successful. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -UPNOrObjectId -The user principal name or the objectId of the user to be deleted. - -```yaml -Type: System.String -Parameter Sets: UPNOrObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -UserPrincipalName -The user principal name of the user to be deleted. - -```yaml -Type: System.String -Parameter Sets: UPNParameterSet -Aliases: UPN - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### Microsoft.Azure.Commands.ActiveDirectory.PSADUser - -## OUTPUTS - -### System.Boolean - -## NOTES - -## RELATED LINKS - -[New-AzADUser](./New-AzADUser.md) - -[Get-AzADUser](./Get-AzADUser.md) - -[Update-AzADUser](./Update-AzADUser.md) - diff --git a/src/Resources/Resources/help/Update-AzADApplication.md b/src/Resources/Resources/help/Update-AzADApplication.md deleted file mode 100644 index f90a613e40ce..000000000000 --- a/src/Resources/Resources/help/Update-AzADApplication.md +++ /dev/null @@ -1,315 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -online version: https://docs.microsoft.com/powershell/module/az.resources/update-azadapplication -schema: 2.0.0 ---- - -# Update-AzADApplication - -## SYNOPSIS -Updates an existing azure active directory application. - -## SYNTAX - -### ApplicationObjectIdWithUpdateParamsParameterSet (Default) -``` -Update-AzADApplication -ObjectId [-DisplayName ] [-HomePage ] - [-IdentifierUri ] [-ReplyUrl ] [-AvailableToOtherTenants ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### ApplicationIdWithUpdateParamsParameterSet -``` -Update-AzADApplication -ApplicationId [-DisplayName ] [-HomePage ] - [-IdentifierUri ] [-ReplyUrl ] [-AvailableToOtherTenants ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### InputObjectWithUpdateParamsParameterSet -``` -Update-AzADApplication -InputObject [-DisplayName ] [-HomePage ] - [-IdentifierUri ] [-ReplyUrl ] [-AvailableToOtherTenants ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Updates an existing azure active directory application. -To update the credentials associated with this application, please use the New-AzADAppCredential cmdlet. - -## EXAMPLES - -### Example 1: Update the display name of an application - -```powershell -PS C:\> Update-AzADApplication -ObjectId fb7b3405-ca44-4b5b-8584-12392f5d96d7 -DisplayName MyNewDisplayName -``` - -Updates the display name of the application with object id 'fb7b3405-ca44-4b5b-8584-12392f5d96d7' to be 'MyNewDisplayName'. - -### Example 2: Update all properties of an application - -```powershell -PS C:\> Update-AzADApplication -ObjectId fb7b3405-ca44-4b5b-8584-12392f5d96d7 -DisplayName MyNewDisplayName -HomePage https://www.microsoft.com -IdentifierUris "https://UpdateAppUri" -``` - -Updates the properties of an application with object id 'fb7b3405-ca44-4b5b-8584-12392f5d96d7'. - -### Example 3: Update the display name of an application using piping - -```powershell -PS C:\> Get-AzADApplication -ObjectId fb7b3405-ca44-4b5b-8584-12392f5d96d7 | Update-AzADApplication -DisplayName MyNewDisplayName -``` - -Gets the application with object id 'fb7b3405-ca44-4b5b-8584-12392f5d96d7' and pipes that to the Update-AzADApplication cmdlet to update the display name of the application to "MyNewDisplayName". - -## PARAMETERS - -### -ApplicationId -The application id of the application to update. - -```yaml -Type: System.Guid -Parameter Sets: ApplicationIdWithUpdateParamsParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -AvailableToOtherTenants -True if the application is shared with other tenants; otherwise, false. - -```yaml -Type: System.Boolean -Parameter Sets: ApplicationObjectIdWithUpdateParamsParameterSet, ApplicationIdWithUpdateParamsParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.Boolean -Parameter Sets: InputObjectWithUpdateParamsParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with Azure. - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name for the application to update. - -```yaml -Type: System.String -Parameter Sets: ApplicationObjectIdWithUpdateParamsParameterSet, ApplicationIdWithUpdateParamsParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.String -Parameter Sets: InputObjectWithUpdateParamsParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -HomePage -The URL to the application's homepage. - -```yaml -Type: System.String -Parameter Sets: ApplicationObjectIdWithUpdateParamsParameterSet, ApplicationIdWithUpdateParamsParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.String -Parameter Sets: InputObjectWithUpdateParamsParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -IdentifierUri -The URIs that identify the application. - -```yaml -Type: System.String[] -Parameter Sets: ApplicationObjectIdWithUpdateParamsParameterSet, ApplicationIdWithUpdateParamsParameterSet -Aliases: IdentifierUris - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.String[] -Parameter Sets: InputObjectWithUpdateParamsParameterSet -Aliases: IdentifierUris - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -InputObject -The object representing the application to update. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADApplication -Parameter Sets: InputObjectWithUpdateParamsParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the application to update. - -```yaml -Type: System.String -Parameter Sets: ApplicationObjectIdWithUpdateParamsParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ReplyUrl -Specifies the URLs that user tokens are sent to for sign in, or the redirect URIs that OAuth 2.0 authorization codes and access tokens are sent to. - -```yaml -Type: System.String[] -Parameter Sets: ApplicationObjectIdWithUpdateParamsParameterSet, ApplicationIdWithUpdateParamsParameterSet -Aliases: ReplyUrls - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.String[] -Parameter Sets: InputObjectWithUpdateParamsParameterSet -Aliases: ReplyUrls - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### System.Guid - -### Microsoft.Azure.Commands.ActiveDirectory.PSADApplication - -### System.String[] - -### System.Boolean - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADApplication - -## NOTES - -## RELATED LINKS diff --git a/src/Resources/Resources/help/Update-AzADServicePrincipal.md b/src/Resources/Resources/help/Update-AzADServicePrincipal.md deleted file mode 100644 index c17b0a27d889..000000000000 --- a/src/Resources/Resources/help/Update-AzADServicePrincipal.md +++ /dev/null @@ -1,287 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -online version: https://docs.microsoft.com/powershell/module/az.resources/update-azadserviceprincipal -schema: 2.0.0 ---- - -# Update-AzADServicePrincipal - -## SYNOPSIS -Updates an existing azure active directory service principal. - -## SYNTAX - -### SpObjectIdWithDisplayNameParameterSet (Default) -``` -Update-AzADServicePrincipal -ObjectId [-DisplayName ] [-Homepage ] - [-IdentifierUri ] [-KeyCredential ] [-PasswordCredential ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### SpApplicationIdWithDisplayNameParameterSet -``` -Update-AzADServicePrincipal -ApplicationId [-Homepage ] [-IdentifierUri ] - [-KeyCredential ] [-PasswordCredential ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### SPNWithDisplayNameParameterSet -``` -Update-AzADServicePrincipal -ServicePrincipalName [-DisplayName ] [-Homepage ] - [-IdentifierUri ] [-KeyCredential ] [-PasswordCredential ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -### InputObjectWithDisplayNameParameterSet -``` -Update-AzADServicePrincipal -InputObject [-DisplayName ] [-Homepage ] - [-IdentifierUri ] [-KeyCredential ] [-PasswordCredential ] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Updates an existing azure active directory service principal. -To update the credentials associated with this service principal, please use New-AzADSpCredential cmdlet. -To update the properties associated with the underlying application, please use Update-AzADApplication cmdlet. - -## EXAMPLES - -### Example 1: Update the display name of a service principal - -```powershell -PS C:\> Update-AzADServicePrincipal -ObjectId 784136ca-3ae2-4fdd-a388-89d793e7c780 -DisplayName MyNewDisplayName -``` - -Updates the display name of the service principal with object id '784136ca-3ae2-4fdd-a388-89d793e7c780' to be 'MyNewDisplayName'. - -### Example 2: Update the display name of a service principal using piping - -```powershell -PS C:\> Get-AzADServicePrincipal -ObjectId 784136ca-3ae2-4fdd-a388-89d793e7c780 | Update-AzADServicePrincipal -DisplayName MyNewDisplayName -``` - -Gets the service principal with object id '784136ca-3ae2-4fdd-a388-89d793e7c780' and pipes that to the Update-AzADServicePrincipal cmdlet to update the display name of the service principal to "MyNewDisplayName". - -### Example 3 - -Updates an existing azure active directory service principal. (autogenerated) - - -```powershell -Update-AzADServicePrincipal -IdentifierUri https://mySecretApp1 -ObjectId 00000000-0000-0000-0000-00000000000000000 -``` - -## PARAMETERS - -### -ApplicationId -The application id of the service principal to update. - -```yaml -Type: System.Guid -Parameter Sets: SpApplicationIdWithDisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with Azure. - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -The display name for the service principal. - -```yaml -Type: System.String -Parameter Sets: SpObjectIdWithDisplayNameParameterSet, SPNWithDisplayNameParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.String -Parameter Sets: InputObjectWithDisplayNameParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Homepage -The homepage for the service principal. - -```yaml -Type: System.String -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -IdentifierUri -The identifier URI(s) for the service principal. - -```yaml -Type: System.String[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The object representing the service principal to update. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal -Parameter Sets: InputObjectWithDisplayNameParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -KeyCredential -The key credential(s) for the service principal. - -```yaml -Type: Microsoft.Azure.Graph.RBAC.Models.KeyCredential[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the service principal to update. - -```yaml -Type: System.String -Parameter Sets: SpObjectIdWithDisplayNameParameterSet -Aliases: ServicePrincipalObjectId - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -PasswordCredential -The password credential(s) for the service principal. - -```yaml -Type: Microsoft.Azure.Graph.RBAC.Models.PasswordCredential[] -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -ServicePrincipalName -The SPN of the service principal to update. - -```yaml -Type: System.String -Parameter Sets: SPNWithDisplayNameParameterSet -Aliases: SPN - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### System.Guid - -### Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADServicePrincipal - -## NOTES - -## RELATED LINKS \ No newline at end of file diff --git a/src/Resources/Resources/help/Update-AzADUser.md b/src/Resources/Resources/help/Update-AzADUser.md deleted file mode 100644 index 628f08d284ee..000000000000 --- a/src/Resources/Resources/help/Update-AzADUser.md +++ /dev/null @@ -1,297 +0,0 @@ ---- -external help file: Microsoft.Azure.PowerShell.Cmdlets.Resources.dll-Help.xml -Module Name: Az.Resources -online version: https://docs.microsoft.com/powershell/module/az.resources/update-azaduser -schema: 2.0.0 ---- - -# Update-AzADUser - -## SYNOPSIS -Updates an existing active directory user. - -## SYNTAX - -### UPNOrObjectIdParameterSet (Default) -``` -Update-AzADUser -UPNOrObjectId [-DisplayName ] [-EnableAccount ] - [-Password ] [-ForceChangePasswordNextLogin] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### UPNParameterSet -``` -Update-AzADUser -UserPrincipalName [-DisplayName ] [-EnableAccount ] - [-Password ] [-ForceChangePasswordNextLogin] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### ObjectIdParameterSet -``` -Update-AzADUser -ObjectId [-DisplayName ] [-EnableAccount ] - [-Password ] [-ForceChangePasswordNextLogin] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -### InputObjectParameterSet -``` -Update-AzADUser -InputObject [-DisplayName ] [-EnableAccount ] - [-Password ] [-ForceChangePasswordNextLogin] [-DefaultProfile ] - [-WhatIf] [-Confirm] [] -``` - -## DESCRIPTION -Updates an existing active directory user (work/school account also popularly known as org-id). -For more information: https://msdn.microsoft.com/en-us/library/azure/ad/graph/api/users-operations#UpdateUser - -## EXAMPLES - -### Example 1: Update the display name of a user using object id - -```powershell -PS C:\> Update-AzADUser -ObjectId 155a5c10-93a9-4941-a0df-96d83ab5ab24 -DisplayName MyNewDisplayName -``` - -Updates the display name of the user with object id '155a5c10-93a9-4941-a0df-96d83ab5ab24' to be 'MyNewDisplayName'. - -### Example 2: Update the display name of a user using user principal name - -```powershell -PS C:\> Update-AzADUser -UserPrincipalName foo@domain.com -DisplayName MyNewDisplayName -``` - -Updates the display name of the user with user principal name 'foo@domain.com' to be 'MyNewDisplayName'. - -### Example 3: Update the display name of a user using piping - -```powershell -PS C:\> Get-AzADUser -ObjectId 155a5c10-93a9-4941-a0df-96d83ab5ab24 | Update-AzADUser -DisplayName MyNewDisplayName -``` - -Gets the user with object id '155a5c10-93a9-4941-a0df-96d83ab5ab24' and pipes that to the Update-AzADUser cmdlet to update the display name of that user to 'MyNewDisplayName'. - -## PARAMETERS - -### -DefaultProfile -The credentials, account, tenant, and subscription used for communication with Azure. - -```yaml -Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer -Parameter Sets: (All) -Aliases: AzContext, AzureRmContext, AzureCredential - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -DisplayName -New display name for the user. - -```yaml -Type: System.String -Parameter Sets: UPNOrObjectIdParameterSet, UPNParameterSet, ObjectIdParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.String -Parameter Sets: InputObjectParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -EnableAccount -true for enabling the account; otherwise, false. - -```yaml -Type: System.Nullable`1[System.Boolean] -Parameter Sets: UPNOrObjectIdParameterSet, UPNParameterSet, ObjectIdParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.Nullable`1[System.Boolean] -Parameter Sets: InputObjectParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -ForceChangePasswordNextLogin -It must be specified if the user should change the password on the next successful login. -Only valid if password is updated otherwise it will be ignored. - -```yaml -Type: System.Management.Automation.SwitchParameter -Parameter Sets: (All) -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: False -Accept wildcard characters: False -``` - -### -InputObject -The object representing the user to be updated. - -```yaml -Type: Microsoft.Azure.Commands.ActiveDirectory.PSADUser -Parameter Sets: InputObjectParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByValue) -Accept wildcard characters: False -``` - -### -ObjectId -The object id of the user to be updated. - -```yaml -Type: System.String -Parameter Sets: ObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Password -New password for the user. - -```yaml -Type: System.Security.SecureString -Parameter Sets: UPNOrObjectIdParameterSet, UPNParameterSet, ObjectIdParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -```yaml -Type: System.Security.SecureString -Parameter Sets: InputObjectParameterSet -Aliases: - -Required: False -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -UPNOrObjectId -The user principal name or object id of the user to be updated. - -```yaml -Type: System.String -Parameter Sets: UPNOrObjectIdParameterSet -Aliases: - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -UserPrincipalName -The user principal name of the user to be updated. - -```yaml -Type: System.String -Parameter Sets: UPNParameterSet -Aliases: UPN - -Required: True -Position: Named -Default value: None -Accept pipeline input: True (ByPropertyName) -Accept wildcard characters: False -``` - -### -Confirm -Prompts you for confirmation before running the cmdlet. - -```yaml -Type: System.Management.Automation.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 is not run. - -```yaml -Type: System.Management.Automation.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](http://go.microsoft.com/fwlink/?LinkID=113216). - -## INPUTS - -### System.String - -### Microsoft.Azure.Commands.ActiveDirectory.PSADUser - -### System.Nullable`1[[System.Boolean, System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]] - -### System.Security.SecureString - -## OUTPUTS - -### Microsoft.Azure.Commands.ActiveDirectory.PSADUser - -## NOTES - -## RELATED LINKS diff --git a/tools/StaticAnalysis/Exceptions/Az.Resources/BreakingChangeIssues.csv b/tools/StaticAnalysis/Exceptions/Az.Resources/BreakingChangeIssues.csv new file mode 100644 index 000000000000..6835d4456347 --- /dev/null +++ b/tools/StaticAnalysis/Exceptions/Az.Resources/BreakingChangeIssues.csv @@ -0,0 +1,27 @@ +"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation" +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.AddAzureADGroupMemberCommand","Add-AzADGroupMember","0","1000","The cmdlet 'Add-AzADGroupMember' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Add-AzADGroupMember' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.GetAzureADAppCredentialCommand","Get-AzADAppCredential","0","1000","The cmdlet 'Get-AzADAppCredential' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Get-AzADAppCredential' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.GetAzureADApplicationCommand","Get-AzADApplication","0","1000","The cmdlet 'Get-AzADApplication' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Get-AzADApplication' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.GetAzureADGroupCommand","Get-AzADGroup","0","1000","The cmdlet 'Get-AzADGroup' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Get-AzADGroup' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.GetAzureADGroupMemberCommand","Get-AzADGroupMember","0","1000","The cmdlet 'Get-AzADGroupMember' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Get-AzADGroupMember' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.GetAzureADServicePrincipalCommand","Get-AzADServicePrincipal","0","1000","The cmdlet 'Get-AzADServicePrincipal' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Get-AzADServicePrincipal' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.GetAzureADSpCredentialCommand","Get-AzADSpCredential","0","1000","The cmdlet 'Get-AzADSpCredential' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Get-AzADSpCredential' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.GetAzureADUserCommand","Get-AzADUser","0","1000","The cmdlet 'Get-AzADUser' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Get-AzADUser' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.NewAzureADAppCredentialCommand","New-AzADAppCredential","0","1000","The cmdlet 'New-AzADAppCredential' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'New-AzADAppCredential' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.NewAzureADApplicationCommand","New-AzADApplication","0","1000","The cmdlet 'New-AzADApplication' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'New-AzADApplication' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.NewAzureADGroupCommand","New-AzADGroup","0","1000","The cmdlet 'New-AzADGroup' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'New-AzADGroup' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.NewAzureADServicePrincipalCommand","New-AzADServicePrincipal","0","1000","The cmdlet 'New-AzADServicePrincipal' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'New-AzADServicePrincipal' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.NewAzureADSpCredentialCommand","New-AzADSpCredential","0","1000","The cmdlet 'New-AzADSpCredential' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'New-AzADSpCredential' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.NewAzureADUserCommand","New-AzADUser","0","1000","The cmdlet 'New-AzADUser' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'New-AzADUser' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.RemoveAzureADAppCredentialCommand","Remove-AzADAppCredential","0","1000","The cmdlet 'Remove-AzADAppCredential' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Remove-AzADAppCredential' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.RemoveAzureADApplicationCommand","Remove-AzADApplication","0","1000","The cmdlet 'Remove-AzADApplication' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Remove-AzADApplication' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.RemoveAzureADGroupCommand","Remove-AzADGroup","0","1000","The cmdlet 'Remove-AzADGroup' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Remove-AzADGroup' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.RemoveAzureADGroupMemberCommand","Remove-AzADGroupMember","0","1000","The cmdlet 'Remove-AzADGroupMember' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Remove-AzADGroupMember' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.RemoveAzureADServicePrincipalCommand","Remove-AzADServicePrincipal","0","1000","The cmdlet 'Remove-AzADServicePrincipal' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Remove-AzADServicePrincipal' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.RemoveAzureADSpCredentialCommand","Remove-AzADSpCredential","0","1000","The cmdlet 'Remove-AzADSpCredential' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Remove-AzADSpCredential' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.RemoveAzureADUserCommand","Remove-AzADUser","0","1000","The cmdlet 'Remove-AzADUser' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Remove-AzADUser' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.UpdateAzureADApplicationCommand","Update-AzADApplication","0","1000","The cmdlet 'Update-AzADApplication' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Update-AzADApplication' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.UpdateAzureADServicePrincipalCommand","Update-AzADServicePrincipal","0","1000","The cmdlet 'Update-AzADServicePrincipal' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Update-AzADServicePrincipal' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.ActiveDirectory.UpdateAzureADUserCommand","Update-AzADUser","0","1000","The cmdlet 'Update-AzADUser' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Update-AzADUser' back to the module, or add an alias to the original cmdlet name." +"Az.Resources","Microsoft.Azure.Commands.Resources.GetAzureDenyAssignmentCommand","Get-AzDenyAssignment","0","2020","The cmdlet 'Get-AzDenyAssignment' no longer supports the type 'System.Guid' for parameter 'Id'.","Change the type for parameter 'Id' back to 'System.Guid'." +"Az.Resources","Microsoft.Azure.Commands.Resources.GetAzureDenyAssignmentCommand","Get-AzDenyAssignment","0","2090","The ValidateNotNullOrEmpty attribute has been added to parameter 'Id' for cmdlet 'Get-AzDenyAssignment'.","Remove the ValidateNotNullOrEmpty attribute from parameter 'Id'."