I am using Powershell SDK in C sharp and and trying to add new website in IIS. But it is not working.
String query = "Import-Module WebAdministration ; New-Website -Name 'testwebsite' -Port 8011 -PhysicalPath '##APPLICATIONFOLDER' -force";
using (PowerShell PowerShellInst = PowerShell.Create())
{
PowerShellInst.AddScript("Set-ExecutionPolicy Bypass -Scope Process; "+ query);
Collection<PSObject> PSOutput = PowerShellInst.Invoke();
PowerShellInst.Commands.Clear();
}
I am getting following error
C:WINDOWSsystem32WindowsPowerShellv1.0ModulesWebAdministrationWebAdministration.psd1' does not support current PowerShell edition 'Core'. Its supported editions are 'Desktop'. Use 'Import-Module -SkipEditionCheck' to ignore the compatibility of this module.
The term 'New-Website' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
When I run new website on actual powershell it works fine.
How I can create new website using c sharp?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…