Guest User

Untitled

a guest
Nov 23rd, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. Import-Module WebAdministration
  2. New-Item "IIS:SitesDefault Web SiteTest" -type Application
  3. Set-ItemProperty "IIS:SitesDefault Web SiteTest" -Name applicationPool -Value "DefaultAppPool"
  4. Set-ItemProperty "IIS:SitesDefault Web SiteTest" -Name physicalPath -Value "D:TempMyWebApp"
  5.  
  6. Cannot retrieve the dynamic parameters for the cmdlet.
  7. Retrieving the COM class factory for component with CLSID
  8. {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error:
  9. 80040154 Class not registered (Exception from HRESULT: 0x80040154
  10. (REGDB_E_CLASSNOTREG)).
  11.  
  12. string script = @"Import-Module WebAdministration
  13. New-Item ""IIS:SitesDefault Web SiteTest"" -type Application
  14. Set-ItemProperty ""IIS:SitesDefault Web SiteTest"" -Name applicationPool -Value ""DefaultAppPool""
  15. Set-ItemProperty ""IIS:SitesDefault Web SiteTest"" -Name physicalPath -Value ""D:Temp_PBWIDestination""";
  16.  
  17.  
  18. using (PowerShell powerShellInstance = PowerShell.Create())
  19. {
  20. powerShellInstance.AddScript(script);
  21.  
  22. Collection<PSObject> psOutput = powerShellInstance.Invoke();
  23.  
  24. if (powerShellInstance.Streams.Error.Count > 0)
  25. {
  26. foreach (var e in powerShellInstance.Streams.Error.Select(a => a.Exception).ToArray())
  27. {
  28. Console.WriteLine(e);
  29. }
  30. }
  31. }
Add Comment
Please, Sign In to add comment