View Complete Thread
  • Importing WebAdministration Module in Powershell Host Application

    Dec 08, 2009 04:58 PM|jyoung0001|LINK

    I am new to Powershell, and am not well versed in Windows administration.  I'd like to be able to run some simple Powershell scripts for managing an IIS 7.5 FTP site from within a VB.NET application. 

    I've created a host, and attempted to invoke the commands using the PowerShell class. 

    I am getting the message "file ...WebAdministrationAliases.ps1 cannot be loaded because the execution of scripts is disabled on this system..." message when I attempt to load the WebAdministration Module.

    A few additional notes:

    • I am running on Win2008R2 64bit, IIS7.5, Powershell 2, Visual Studio 2010 Beta 2.
    • I am running as administrator
    • I can run the commands from within Powershell just fine, assuming I run the Set-ExecutionPolicy and Import-Module commands first.
    • I've tried loading the module via both the InitialSessionState.ImportPSModule method, and the AddCommand("Import-Module WebAdministration").
    • I've tried passing Set-ExecutionPolicy Unrestricted via the AddCommand method, but it returns an error message stating that "The term 'Set-ExecutionPolicy Unrestricted' is not recognized as the name of a cmdlet, function, script file, or operable program..."
    • My application is signed.

    I'm sure I'm missing something simple, but I'm at a loss for what to try next to give this application the appropriate permissions.  Any help would be appreciated.

    PowerShell IIS Powershell IIS7 powerShell script FTP WebAdministration IIS 7.5