Question: Need assistance with RDK construct using import module webadministration
I have a powershell script that runs successfully as a standalone script. I am trying to use RDK to create an action and getting errors. I suspect that the import module is failing based on the error that I receive.
Note also that the reason I require using webadministration module is because I want to continue to build actions – one of which is to retrieve the app pool name from the site name… so that we can recycle the app pool.
Here is my script:
$sitename = ${SiteName}
#$sitename = "authenticationservice"
import-module webadministration
set-location "iis:\sites"
try
{
start-webitem $siteName
}
catch
{
#$global:test = $_
Write-Warning ($_.exception.message)
}
After importing into RA and running…
Below is the message. Note that iis:\sites is only exposed from the webadministration module… which is why I am thinking that is where the issue lies…that the module import is not successful
Inputs: | | SiteName | authenticationservice | | Outputs: | | Execution Output | null | Error Output | authenticationservice : The term 'authenticationservice' 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. At C:\Users\nolioservice\AppData\Local\Temp\tempCommand_5902796750199227731.ps1:3 char:14 + $sitename = authenticationservice + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (authenticationservice:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException set-location : Retrieving the COM class factory for component with CLSID {688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). At C:\Users\nolioservice\AppData\Local\Temp\tempCommand_5902796750199227731.ps1:7 char:1 + set-location "iis:\sites" + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Set-Location], COMException + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.PowerShell.Commands.SetLocationCommand start-webitem : Command start is not applicable to the item on path IIS:\. At C:\Users\nolioservice\AppData\Local\Temp\tempCommand_5902796750199227731.ps1:13 char:1 + start-webitem $siteName + ~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (System.String[]:String[]) [Start-WebItem], ArgumentException + FullyQualifiedErrorId : InvalidOperation,Microsoft.IIs.PowerShell.Provider.StartItemCommand | Exit Code | 0 | Return Code | 0 |
|
For comparison, on my test server if I attempt to run this without the import module: here are my results:
start-webitem : Command start is not applicable to the item on path IIS:\.
At C:\Users\lewister\Documents\scripts\test_start_site wo module 16sep.ps1:13 char:1
+ start-webitem $siteName
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.String[]:String[]) [Start-WebItem], ArgumentException
+ FullyQualifiedErrorId : InvalidOperation,Microsoft.IIs.PowerShell.Provider.StartItemCommand