protected override void ExecuteCmdlet() { // Ensure that with ParameterSet_OTHERSITE we either receive a ServerRelativeUrl or SiteRelativeUrl if (ParameterSetName == ParameterSet_OTHERSITE && !ParameterSpecified(nameof(ServerRelativeUrl)) && !ParameterSpecified(nameof(SiteRelativeUrl))) { throw new PSArgumentException($"Either provide {nameof(ServerRelativeUrl)} or {nameof(SiteRelativeUrl)}"); } if (ParameterSpecified(nameof(SiteRelativeUrl))) { var webUrl = SelectedWeb.EnsureProperty(w => w.ServerRelativeUrl); ServerRelativeUrl = UrlUtility.Combine(webUrl, SiteRelativeUrl); } var file = SelectedWeb.GetFileByServerRelativePath(ResourcePath.FromDecodedUrl(ServerRelativeUrl)); ClientContext.Load(file, f => f.Name, f => f.ServerRelativeUrl); ClientContext.ExecuteQueryRetry(); if (Force || ShouldContinue(string.Format(Resources.MoveFile0To1, ServerRelativeUrl, TargetUrl), Resources.Confirm)) { switch (ParameterSetName) { case ParameterSet_SITE: case ParameterSet_SERVER: file.MoveToUsingPath(ResourcePath.FromDecodedUrl(TargetUrl), OverwriteIfAlreadyExists.ToBool() ? MoveOperations.Overwrite : MoveOperations.None); break; case ParameterSet_OTHERSITE: SelectedWeb.EnsureProperties(w => w.Url, w => w.ServerRelativeUrl); // Create full URLs including the SharePoint domain to the source and destination var source = UrlUtility.Combine(SelectedWeb.Url.Remove(SelectedWeb.Url.Length - SelectedWeb.ServerRelativeUrl.Length + 1, SelectedWeb.ServerRelativeUrl.Length - 1), file.ServerRelativeUrl); var destination = UrlUtility.Combine(SelectedWeb.Url.Remove(SelectedWeb.Url.Length - SelectedWeb.ServerRelativeUrl.Length + 1, SelectedWeb.ServerRelativeUrl.Length - 1), TargetServerRelativeLibrary); ClientContext.Site.CreateCopyJobs(new[] { source }, destination, new CopyMigrationOptions { IsMoveMode = true, AllowSchemaMismatch = AllowSchemaMismatch.ToBool(), AllowSmallerVersionLimitOnDestination = AllowSmallerVersionLimitOnDestination.ToBool(), IgnoreVersionHistory = IgnoreVersionHistory.ToBool(), NameConflictBehavior = OverwriteIfAlreadyExists.ToBool() ? MigrationNameConflictBehavior.Replace : MigrationNameConflictBehavior.Fail }); break; default: throw new PSInvalidOperationException(string.Format(Resources.ParameterSetNotImplemented, ParameterSetName)); } ClientContext.ExecuteQueryRetry(); } }
protected override void ExecuteCmdlet() { var hubSiteProperties = Identity.GetHubSite(Tenant); ClientContext.Load(hubSiteProperties); if (MyInvocation.BoundParameters.ContainsKey("Title")) { hubSiteProperties.Title = Title; } if (MyInvocation.BoundParameters.ContainsKey("LogoUrl")) { hubSiteProperties.LogoUrl = LogoUrl; } if (MyInvocation.BoundParameters.ContainsKey("Description")) { hubSiteProperties.Description = Description; } if (MyInvocation.BoundParameters.ContainsKey("SiteDesignId")) { hubSiteProperties.SiteDesignId = SiteDesignId.Id; } if (MyInvocation.BoundParameters.ContainsKey(nameof(HideNameInNavigation))) { hubSiteProperties.HideNameInNavigation = HideNameInNavigation.ToBool(); } if (MyInvocation.BoundParameters.ContainsKey(nameof(RequiresJoinApproval))) { hubSiteProperties.RequiresJoinApproval = RequiresJoinApproval.ToBool(); } hubSiteProperties.Update(); ClientContext.ExecuteQueryRetry(); }
protected (string, Func <TDto, bool>) BuildFilter <TDto>() { Func <TDto, bool> localFilter = (dto) => true; StringBuilder sb = new StringBuilder(); string and = null; foreach (var p in this.GetType() .GetProperties() .Where(pi => MyInvocation.BoundParameters.ContainsKey(pi.Name)) .Where(pi => pi.GetCustomAttributes(true) .Where(o => o is FilterAttribute) .Any())) { var value = p.GetValue(this); if (value != null) { var type = value.GetType(); if (type.IsAssignableFrom(typeof(SwitchParameter))) { SwitchParameter sw = (SwitchParameter)value; value = sw.ToBool(); } type = value.GetType(); // value may had changed above string eqToken; if (type.IsAssignableFrom(typeof(bool))) { eqToken = (bool)value ? "true" : "false"; // OData view of True and False } else if (type.IsAssignableFrom(typeof(long)) || type.IsAssignableFrom(typeof(int))) { eqToken = value.ToString(); // "1" or "42" } else if (type.IsAssignableFrom(typeof(Guid))) { eqToken = $"'{value}'"; } else { eqToken = $"'{HttpUtility.UrlEncode(value.ToString().Replace("'", "''"))}'"; } sb.Append($"{and}{p.Name} eq {eqToken}"); var dtoProperty = typeof(TDto).GetProperty(p.Name); if (dtoProperty != null) { var oldFilter = localFilter; Func <TDto, bool> newFilter = (dto) => { var dtoValue = dtoProperty.GetValue(dto); return(string.Compare(dtoValue.ToString(), value.ToString()) == 0); }; localFilter = (dto) => oldFilter(dto) && newFilter(dto); } and = " and "; } } WriteVerbose($"filter: {sb}"); return(sb.Length > 0 ? sb.ToString() : null, localFilter); }
/// <summary> /// Abstracts out the regular settings that keep getting applied /// </summary> private void ApplyCommonSettings() { if (!String.IsNullOrEmpty(Description)) { _Config.Description = Description; } if (Handler != null) { _Config.Handler = Handler; } if (!String.IsNullOrEmpty(Validation)) { _Config.Validation = ConfigurationHost.Validation[Validation]; } if (Hidden.IsPresent) { _Config.Hidden = Hidden; } if (SimpleExport.IsPresent) { _Config.SimpleExport = SimpleExport.ToBool(); } if (ModuleExport.IsPresent) { _Config.ModuleExport = ModuleExport.ToBool(); } // Will be silently ignored if the setting is already initialized. if (AllowDelete.IsPresent) { _Config.AllowDelete = AllowDelete.ToBool(); } }
/// <summary> /// Applies a value to a configuration item, invoking validation and handler scriptblocks. /// </summary> /// <param name="Value">The value to apply</param> private void ApplyValue(object Value) { object tempValue = Value; #region Validation if (!DisableValidation.ToBool() && (_Config.Validation != null)) { PSObject validationResult = _Config.Validation.InvokeEx(true, tempValue, tempValue, null, true, true, new object[] { tempValue })[0]; if (!(bool)validationResult.Properties["Success"].Value) { _ValidationErrorMessage = (string)validationResult.Properties["Message"].Value; throw new ArgumentException(String.Format("Failed validation: {0}", _ValidationErrorMessage)); } tempValue = validationResult.Properties["Value"].Value; } #endregion Validation #region Handler if (!DisableHandler.ToBool() && (_Config.Handler != null)) { object handlerValue = tempValue; if ((tempValue != null) && ((tempValue as ICollection) != null)) { handlerValue = new object[1] { tempValue } } ; _Config.Handler.InvokeEx(true, handlerValue, handlerValue, null, true, true, new object[] { handlerValue }); } #endregion Handler _Config.Value = tempValue; }
/// <summary> /// Process items as they are passed to the cmdlet /// </summary> protected override void ProcessRecord() { if (InputObject == null) { return; } //PSObject tempObject = InputObject as PSObject; if (!AllowEmptyStrings.IsPresent || !AllowEmptyStrings.ToBool()) { string tempString = InputObject.BaseObject as string; if (tempString == "") { return; } } if (!AllowEmptyCollections.IsPresent || !AllowEmptyCollections.ToBool()) { ICollection tempCollection = InputObject.BaseObject as ICollection; if ((tempCollection != null) && (tempCollection.Count == 0)) { return; } } WriteObject(InputObject, Enumerate); }
protected override void ExecuteCmdlet() { if (Scope == Enums.DisableSpacesScope.Tenant) { Tenant.DisableSpacesActivation = Disable.ToBool(); } else { if (!ParameterSpecified(nameof(Identity)) || string.IsNullOrEmpty(Identity.Url)) { throw new ArgumentNullException($"{nameof(Identity)} must be provided when setting {nameof(Scope)} to Site"); } Tenant.DisableSpacesActivationOnSite(Identity.Url, Disable.ToBool()); } ClientContext.ExecuteQueryRetry(); }
protected override void ExecuteCmdlet() { UnifiedGroupEntity group = null; List <UnifiedGroupEntity> groups = null; #pragma warning disable 0618 var includeSiteUrl = ParameterSpecified(nameof(ExcludeSiteUrl)) ? !ExcludeSiteUrl.ToBool() : IncludeSiteUrl.ToBool(); #pragma warning restore 0618 if (Identity != null) { group = Identity.GetGroup(AccessToken, includeSite: includeSiteUrl); } else { groups = UnifiedGroupsUtility.GetUnifiedGroups(AccessToken, includeSite: IncludeSiteUrl, includeClassification: IncludeClassification.IsPresent, includeHasTeam: IncludeHasTeam.IsPresent); } if (group != null) { WriteObject(group); } else if (groups != null) { WriteObject(groups, true); } }
protected override void ExecuteCmdlet() { UnifiedGroupEntity group = null; if (Identity != null) { group = Identity.GetGroup(AccessToken); } Stream groupLogoStream = null; if (group != null) { if (GroupLogoPath != null) { if (!Path.IsPathRooted(GroupLogoPath)) { GroupLogoPath = Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, GroupLogoPath); } groupLogoStream = new FileStream(GroupLogoPath, FileMode.Open, FileAccess.Read); } bool?isPrivateGroup = null; if (IsPrivate.IsPresent) { isPrivateGroup = IsPrivate.ToBool(); } UnifiedGroupsUtility.UpdateUnifiedGroup(group.GroupId, AccessToken, displayName: DisplayName, description: Description, owners: Owners, members: Members, groupLogo: groupLogoStream, isPrivate: isPrivateGroup); } else { WriteError(new ErrorRecord(new Exception("Group not found"), "GROUPNOTFOUND", ErrorCategory.ObjectNotFound, this)); } }
/// <summary> /// Implements the process action of Set-PSFConfig /// </summary> protected override void ProcessRecord() { if (_KillIt) { return; } if (_Initialize) { ExecuteInitialize(); } else if (!_Exists && _Persisted) { ExecuteNewPersisted(); } else if (_Exists && _Persisted) { ExecuteUpdatePersisted(); } else if (_Exists) { ExecuteUpdate(); } else { ExecuteNew(); } if (PassThru.ToBool() && (_Config != null)) { WriteObject(_Config); } }
/// <summary> /// Processes the items to split /// </summary> protected override void ProcessRecord() { foreach (string item in InputString) { if (DoNotUseRegex.ToBool()) { if (Count > 0) { WriteObject(item.Split(_Separator, Count), true); } else { WriteObject(item.Split(_Separator), true); } } else { if (Count < 1) { WriteObject(Regex.Split(item, Separator, Options), true); } else { Regex regex = new Regex(Separator, Options); WriteObject(regex.Split(item, Count), true); } } } }
protected override void ExecuteCmdlet() { var hubSiteProperties = Identity.GetHubSite(Tenant); ClientContext.Load(hubSiteProperties); if (ParameterSpecified(nameof(Title))) { hubSiteProperties.Title = Title; } if (ParameterSpecified(nameof(LogoUrl))) { hubSiteProperties.LogoUrl = LogoUrl; } if (ParameterSpecified(nameof(Description))) { hubSiteProperties.Description = Description; } if (ParameterSpecified(nameof(SiteDesignId))) { hubSiteProperties.SiteDesignId = SiteDesignId.Id; } if (ParameterSpecified(nameof(HideNameInNavigation))) { hubSiteProperties.HideNameInNavigation = HideNameInNavigation.ToBool(); } if (ParameterSpecified(nameof(RequiresJoinApproval))) { hubSiteProperties.RequiresJoinApproval = RequiresJoinApproval.ToBool(); } hubSiteProperties.Update(); ClientContext.ExecuteQueryRetry(); }
protected override void ExecuteCmdlet() { UnifiedGroupEntity group = null; if (Identity != null) { group = Identity.GetGroup(AccessToken); } Stream groupLogoStream = null; if (group != null) { if (GroupLogoPath != null) { if (!Path.IsPathRooted(GroupLogoPath)) { GroupLogoPath = Path.Combine(SessionState.Path.CurrentFileSystemLocation.Path, GroupLogoPath); } groupLogoStream = new FileStream(GroupLogoPath, FileMode.Open, FileAccess.Read); } bool?isPrivateGroup = null; if (IsPrivate.IsPresent) { isPrivateGroup = IsPrivate.ToBool(); } try { UnifiedGroupsUtility.UpdateUnifiedGroup( groupId: group.GroupId, accessToken: AccessToken, displayName: DisplayName, description: Description, owners: Owners, members: Members, groupLogo: groupLogoStream, isPrivate: isPrivateGroup, createTeam: CreateTeam); if (ParameterSpecified(nameof(HideFromAddressLists)) || ParameterSpecified(nameof(HideFromOutlookClients))) { // For this scenario a separate call needs to be made UnifiedGroupsUtility.SetUnifiedGroupVisibility(group.GroupId, AccessToken, HideFromAddressLists, HideFromOutlookClients); } } catch (Exception e) { while (e.InnerException != null) { e = e.InnerException; } WriteError(new ErrorRecord(e, "GROUPUPDATEFAILED", ErrorCategory.InvalidOperation, this)); } } else { WriteError(new ErrorRecord(new Exception("Group not found"), "GROUPNOTFOUND", ErrorCategory.ObjectNotFound, this)); } }
protected override void ProcessRecord() { if (Password == null || Password.Length == 0) { Host.UI.Write("Enter password: "); Password = Host.UI.ReadLineAsSecureString(); } Utilities.CredentialManager.AddCredential(Name, Username, Password, Overwrite.ToBool()); }
/// <summary> /// Allows copying to another site collection /// </summary> private void CopyToOtherSiteCollection(Uri source, Uri destination) { ClientContext.Site.CreateCopyJobs(new[] { source.ToString() }, destination.ToString(), new CopyMigrationOptions { IsMoveMode = false, IgnoreVersionHistory = IgnoreVersionHistory.ToBool(), NameConflictBehavior = OverwriteIfAlreadyExists.ToBool() ? MigrationNameConflictBehavior.Replace : MigrationNameConflictBehavior.Fail }); ClientContext.ExecuteQueryRetry(); }
protected override void ExecuteCmdlet() { if (Term.Item == null) { throw new ArgumentException("You must pass in a Term instance to this command", nameof(Term)); } var label = Term.Item.CreateLabel(Name, Lcid, IsDefault.IsPresent ? IsDefault.ToBool() : true); ClientContext.ExecuteQueryRetry(); WriteObject(label); }
/// <summary> /// Handles the input conversion on the What parameter /// </summary> protected override void BeginProcessing() { if (NewValue == null) { StringValue = ""; } else if (!DoNotUseRegex.ToBool() && (NewValue is ScriptBlock)) { ScriptBlockValue = (ScriptBlock)NewValue; _DoInvokeReturnAsIs = typeof(ScriptBlock).GetMethod("DoInvokeReturnAsIs", BindingFlags.Instance | BindingFlags.NonPublic); ScriptBlockEvaluator = match => { object[] parameters = new object[] { false, 2, match, null, null, null }; var result = _DoInvokeReturnAsIs.Invoke(ScriptBlockValue, parameters); return(LanguagePrimitives.ConvertTo <string>(result)); }; } else { StringValue = NewValue.ToString(); } }
protected override void ExecuteCmdlet() { AzureADGroup group = null; if (Identity != null) { group = Identity.GetGroup(AccessToken); } if (group != null) { GroupsUtility.AddGroupOwners(group.Id, Users, AccessToken, RemoveExisting.ToBool()); } }
/// <summary> /// Implements the begin action of the command /// </summary> protected override void BeginProcessing() { object outBuffer; if (MyInvocation.BoundParameters.TryGetValue("OutBuffer", out outBuffer)) { MyInvocation.BoundParameters["OutBuffer"] = 1; } Hashtable clonedBoundParameters = new Hashtable(); foreach (string key in MyInvocation.BoundParameters.Keys) { if (!_NonclonedProperties.Contains(key)) { clonedBoundParameters[key] = MyInvocation.BoundParameters[key]; } } if (MyInvocation.BoundParameters.ContainsKey("Property")) { clonedBoundParameters["Property"] = Property.Select(o => o.Value).AsEnumerable().ToArray(); } if ((ShowExcludeProperty.Length > 0) || (ShowProperty.Length > 0) || (!String.IsNullOrEmpty(TypeName)) || (KeepInputObject.ToBool())) { _NoAdjustment = false; } if (ShowProperty.Length > 0) { _DisplayPropertySet = new PSMemberInfo[] { new PSPropertySet("DefaultDisplayPropertySet", ShowProperty) } } ; // Set the list of parameters to a variable in the caller scope, so it can be splatted this.SessionState.PSVariable.Set("__PSFramework_SelectParam", clonedBoundParameters); ScriptBlock scriptCommand = ScriptBlock.Create("Select-Object @__PSFramework_SelectParam"); _Pipeline = scriptCommand.GetSteppablePipeline(MyInvocation.CommandOrigin); if (_NoAdjustment) { _Pipeline.Begin(this); } else { _Pipeline.Begin(true); } }
protected override void ProcessRecord() { if (Password == null || Password.Length == 0) { Host.UI.Write("Enter password: "); Password = Host.UI.ReadLineAsSecureString(); } #if !NETSTANDARD2_0 CredentialManager.AddCredential(Name, Username, Password); #else CredentialManager.AddCredential(Name, Username, Password, Overwrite.ToBool()); #endif }
private void ExecuteInitialize() { object oldValue = null; if (_Exists) { oldValue = _Config.Value; } else { _Config = new Config(); } _Config.Name = _NameName; _Config.Module = _NameModule; _Config.Value = Value; ApplyCommonSettings(); // Do it again even though it is part of common settings // The common settings are only applied if the parameter is set, this always will. _Config.AllowDelete = AllowDelete.ToBool(); _Config.Initialized = true; ConfigurationHost.Configurations[_NameFull] = _Config; if (_Exists) { try { ApplyValue(oldValue); } catch (Exception e) { InvokeCommand.InvokeScript(true, ScriptBlock.Create(String.Format(_updateError, _NameFull, EnableException.ToBool())), null, e); _KillIt = true; return; } } }
/// <summary> /// Applies a value to a configuration item, invoking validation and handler scriptblocks. /// </summary> /// <param name="Value">The value to apply</param> private void ApplyValue(object Value) { object tempValue = Value; #region Validation if (!DisableValidation.ToBool() && (!String.IsNullOrEmpty(_Config.Validation))) { ScriptBlock tempValidation = ScriptBlock.Create(_Config.Validation.ToString()); //if ((tempValue != null) && ((tempValue as ICollection) != null)) // tempValue = new object[1] { tempValue }; PSObject validationResult = tempValidation.Invoke(tempValue)[0]; if (!(bool)validationResult.Properties["Success"].Value) { _ValidationErrorMessage = (string)validationResult.Properties["Message"].Value; throw new ArgumentException(String.Format("Failed validation: {0}", _ValidationErrorMessage)); } tempValue = validationResult.Properties["Value"].Value; } #endregion Validation #region Handler if (!DisableHandler.ToBool() && (_Config.Handler != null)) { object handlerValue = tempValue; ScriptBlock tempHandler = ScriptBlock.Create(_Config.Handler.ToString()); if ((tempValue != null) && ((tempValue as ICollection) != null)) { handlerValue = new object[1] { tempValue } } ; tempHandler.Invoke(handlerValue); } #endregion Handler _Config.Value = tempValue; if (Register.ToBool()) { ScriptBlock registerCodeblock = ScriptBlock.Create(@" param ($Config) $Config | Register-DbatoolsConfig "); registerCodeblock.Invoke(_Config); } }
private void ExecuteInitialize() { object oldValue = null; if (_Exists) { oldValue = _Config.Value; } else { _Config = new Config(); } _Config.Name = _NameName; _Config.Module = _NameModule; _Config.Value = Value; ApplyCommonSettings(); // Do it again even though it is part of common settings // The common settings are only applied if the parameter is set, this always will. _Config.AllowDelete = AllowDelete.ToBool(); _Config.Initialized = true; ConfigurationHost.Configurations[_NameFull] = _Config; if (_Exists) { try { ApplyValue(oldValue); } catch (Exception e) { StopCommand($"Could not update configuration: {_NameFull}", e, _NameFull, "Set-PSFConfig", "PSFramework", "SetPSFConfigCommand.cs", 0, null, EnableException.ToBool()); return; } } }
protected override void ProcessRecord() { if (this._DHCP) { if (base.ParameterDictionary.ContainsKey("SetHostNameInDhcp") && base.ParameterDictionary["SetHostNameInDhcp"].IsSet) { SwitchParameter temp = (SwitchParameter)base.ParameterDictionary["SetHostNameInDhcp"].Value; this._SetHostName = temp.ToBool(); } } if (base.ParameterDictionary.ContainsKey("MAC") && base.ParameterDictionary["MAC"].IsSet) { this._MAC = base.ParameterDictionary["MAC"].Value as string; } switch (this.ParameterSetName) { case _GRID_SPECIFY_IP: case _SESSION_SPECIFY_IP: case _ENTERED_SESSION_SPECIFY_IP: { ProcessByIp(); break; } case _GRID_NEXT_AVAILABLE_IP: case _SESSION_NEXT_AVAILABLE_IP: case _ENTERED_SESSION_NEXT_AVAILABLE_IP: { ProcessByNextAvailableIp(); break; } case _GRID_BY_OBJECT: case _SESSION_BY_OBJECT: case _ENTERED_SESSION_BY_OBJECT: { base.ProcessByNewObject(this.InputObject); break; } default: { throw new PSArgumentException("Bad ParameterSet Name"); } } }
private Dictionary<string, object> CreateCommonParameters() { Dictionary<string, object> strs = new Dictionary<string, object>(); SwitchParameter runAs32 = this.RunAs32; strs.Add("RunAs32", runAs32.ToBool()); strs.Add("Authentication", this.Authentication); if (this.InitializationScript != null) { strs.Add("InitializationScript", this.InitializationScript); } if (this.ArgumentList != null) { strs.Add("ArgumentList", this.ArgumentList); } return strs; }
internal static CommandDispatcher <T> Create <TS>(TS cmdlet, SwitchParameter noLockSwitch) where TS : PSCmdlet, IProvideAssemblyResolutionProbingPaths, ISetupCommandProxy <T> { if (cmdlet == null) { throw new ArgumentNullException(nameof(cmdlet)); } var assemblyResolutionProbingPaths = cmdlet.AssemblyResolutionProbingPaths; var commandProxySetupper = (ISetupCommandProxy <T>)cmdlet; var outputAppender = new PowerShellOutputAppender(cmdlet); return(noLockSwitch.IsPresent && noLockSwitch.ToBool() ? new IsolatedCommandDispatcher <T>(outputAppender, commandProxySetupper, assemblyResolutionProbingPaths) : new CommandDispatcher <T>(outputAppender, commandProxySetupper, assemblyResolutionProbingPaths)); }
protected override void ExecuteCmdlet() { bool isDirty = false; if (ParameterSpecified(nameof(Enabled))) { SelectedWeb.FooterEnabled = Enabled.ToBool(); isDirty = true; } if (ParameterSpecified(nameof(Layout))) { SelectedWeb.FooterLayout = Layout; isDirty = true; } if (ParameterSpecified(nameof(BackgroundTheme))) { SelectedWeb.FooterEmphasis = BackgroundTheme; isDirty = true; } if (ParameterSpecified(nameof(Title))) { SelectedWeb.SetFooterTitle(Title); // No isDirty is needed here as the above request will directly perform the update } if (ParameterSpecified(nameof(LogoUrl))) { if (LogoUrl == string.Empty) { SelectedWeb.RemoveFooterLogoUrl(); } else { SelectedWeb.SetFooterLogoUrl(LogoUrl); } // No isDirty is needed here as the above request will directly perform the update } if (isDirty) { SelectedWeb.Update(); ClientContext.ExecuteQueryRetry(); } }
protected override void ExecuteCmdlet() { #pragma warning disable 0618 var includeSiteUrl = ParameterSpecified(nameof(ExcludeSiteUrl)) ? !ExcludeSiteUrl.ToBool() : IncludeSiteUrl.ToBool(); #pragma warning restore 0618 if (Identity != null) { var group = Identity.GetGroup(HttpClient, AccessToken, includeSiteUrl, IncludeOwners); WriteObject(group); } else { var groups = Microsoft365GroupsUtility.GetGroupsAsync(HttpClient, AccessToken, includeSiteUrl, IncludeOwners).GetAwaiter().GetResult(); WriteObject(groups.OrderBy(p => p.DisplayName), true); } }
protected override void ExecuteCmdlet() { ClientContext.Load(Tenant); ClientContext.ExecuteQueryRetry(); if (ParameterSpecified(nameof(DomainGuids))) { Tenant.AllowedDomainListForSyncClient = new List <Guid>(DomainGuids); } Tenant.BlockMacSync = BlockMacSync.ToBool(); Tenant.IsUnmanagedSyncClientForTenantRestricted = Enable.ToBool(); Tenant.DisableReportProblemDialog = DisableReportProblemDialog.ToBool(); if (ParameterSpecified(nameof(ExcludedFileExtensions))) { Tenant.ExcludedFileExtensionsForSyncClient = ExcludedFileExtensions; } if (ParameterSpecified(nameof(GrooveBlockOption))) { switch (GrooveBlockOption) { case Enums.GrooveBlockOption.OptOut: Tenant.OptOutOfGrooveBlock = true; Tenant.OptOutOfGrooveSoftBlock = true; break; case Enums.GrooveBlockOption.HardOptin: Tenant.OptOutOfGrooveBlock = false; Tenant.OptOutOfGrooveSoftBlock = true; break; case Enums.GrooveBlockOption.SoftOptin: Tenant.OptOutOfGrooveBlock = true; Tenant.OptOutOfGrooveSoftBlock = false; break; default: throw new PSArgumentException(string.Format(Resources.GrooveBlockOptionNotSupported, nameof(GrooveBlockOption), GrooveBlockOption), nameof(GrooveBlockOption)); } } ClientContext.ExecuteQueryRetry(); }
protected override void ExecuteCmdlet() { if (PnPConnection.Current.ClientId == PnPConnection.PnPManagementShellClientId) { PnPConnection.Current.Scopes = new[] { "Group.ReadWrite.All" }; } AzureADGroup group = null; if (Identity != null) { group = Identity.GetGroup(AccessToken); } if (group != null) { GroupsUtility.AddGroupMembers(group.Id, Users, AccessToken, RemoveExisting.ToBool()); } }