/// <summary> /// Handles the SPWebApplicationEnumerated event of the enumerator control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Lapointe.SharePoint.STSADM.Commands.OperationHelpers.SPEnumerator.SPWebApplicationEventArgs"/> instance containing the event data.</param> private void OnSPWebApplicationEnumerated(object sender, SPEnumerator.SPWebApplicationEventArgs e) { if (!_includeIis) { return; } foreach (SPIisSettings iis in e.WebApplication.IisSettings.Values) { string iisBakPath = Path.Combine(_path, string.Format("iis_w3svc_{0}.bak", iis.PreferredInstanceId)); if (_overwrite && File.Exists(iisBakPath)) { File.Delete(iisBakPath); } if (!_overwrite && File.Exists(iisBakPath)) { throw new SPException(string.Format("The IIS backup file '{0}' already exists - specify '-overwrite' to replace the file.", iisBakPath)); } //Utilities.RunCommand( // "cscript", // string.Format("{0}\\iiscnfg.vbs /export /f \"{1}\" /inherited /children /sp /lm/w3svc/{2}", // Environment.SystemDirectory, // iisBakPath, // iis.PreferredInstanceId), // false); using (DirectoryEntry de = new DirectoryEntry("IIS://localhost")) { Logger.Write("Exporting IIS settings for web application '{0}'....", iis.ServerComment); string decryptionPwd = string.Empty; string path = string.Format("/lm/w3svc/{0}", iis.PreferredInstanceId); de.Invoke("Export", new object[] { decryptionPwd, iisBakPath, path, FLAG_EXPORT_INHERITED_SETTINGS }); } } }
/// <summary> /// Handles the SPWebApplicationEnumerated event of the enumerator control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="Lapointe.SharePoint.STSADM.Commands.OperationHelpers.SPEnumerator.SPWebApplicationEventArgs"/> instance containing the event data.</param> private void enumerator_SPWebApplicationEnumerated(object sender, SPEnumerator.SPWebApplicationEventArgs e) { ActivateDeactivateFeatureAtWebApplication(e.WebApplication, m_FeatureId, m_Activate, m_Force, m_IgnoreNonActive); }