-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add groupSetting to cmdlet Get-PnPMicrosoft365GroupSettings (#4481)
* Update GetGroupSettings * Update to get group settings * Add groupsetting parameter to the cmdlet --------- Co-authored-by: Gautam Sheth <[email protected]>
- Loading branch information
1 parent
65f61bb
commit ac31865
Showing
4 changed files
with
137 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/Commands/Base/PipeBinds/Microsoft365GroupSettingsPipeBind.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
using PnP.PowerShell.Commands.Model; | ||
using PnP.PowerShell.Commands.Utilities; | ||
using System; | ||
using System.Management.Automation; | ||
|
||
namespace PnP.PowerShell.Commands.Base.PipeBinds | ||
{ | ||
public class Microsoft365GroupSettingsPipeBind | ||
{ | ||
private readonly Microsoft365GroupSetting _group; | ||
private readonly Guid _groupId; | ||
private readonly string _displayName; | ||
|
||
public Microsoft365GroupSettingsPipeBind() | ||
{ | ||
} | ||
|
||
public Microsoft365GroupSettingsPipeBind(Microsoft365GroupSetting group) | ||
{ | ||
_group = group; | ||
} | ||
|
||
public Microsoft365GroupSettingsPipeBind(string input) | ||
{ | ||
Guid idValue; | ||
if (Guid.TryParse(input, out idValue)) | ||
{ | ||
_groupId = idValue; | ||
} | ||
else | ||
{ | ||
_displayName = input; | ||
} | ||
} | ||
|
||
public Microsoft365GroupSettingsPipeBind(Guid guid) | ||
{ | ||
_groupId = guid; | ||
} | ||
|
||
public Microsoft365GroupSetting Group => _group; | ||
|
||
public string DisplayName => _displayName; | ||
|
||
public Guid GroupId => _groupId; | ||
|
||
public Guid GetGroupSettingId(Cmdlet cmdlet, PnPConnection connection, string accessToken) | ||
{ | ||
Guid idValue; | ||
if (Group != null) | ||
{ | ||
Guid.TryParse(Group.Id, out idValue); | ||
return idValue; | ||
} | ||
else if (_groupId != Guid.Empty) | ||
{ | ||
return _groupId; | ||
} | ||
else if (!string.IsNullOrEmpty(DisplayName)) | ||
{ | ||
var groups = ClearOwners.GetGroupSettings(cmdlet, connection, accessToken); | ||
if (groups != null) | ||
{ | ||
var group = groups.Value.Find(p => p.DisplayName.Equals(DisplayName)); | ||
if (group != null) | ||
{ | ||
Guid.TryParse(group.Id, out idValue); | ||
return idValue; | ||
} | ||
} | ||
} | ||
throw new PSInvalidOperationException("Group not found"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters