powershell - Webadministration module is not imported while running from C# application -


on button click event, following script run. when services executed, not display in text file , import module webadministration line shows error message :

cannot find provider name 'webadministration'

same script runs fine powershell cmd

my script:

        $a = (get-service | {$_.displayname -like "microsoft exchange*"} | % {$_.name + ' :' + $_.status}) -join "`n"           write-output $a >> c:\temp.txt               import-module webadministration         $webapps = get-website powershell         $list = @()         foreach ($webapp in get-childitem iis:\apppools\)         {                 $name = "iis:\apppools\" + $webapp.name                 $item = @{}                  $item.webappname = $webapp.name                 $item.version = (get-itemproperty $name managedruntimeversion).value                 $item.state = (get-webapppoolstate -name $webapp.name).value                 $item.useridentitytype = $webapp.processmodel.identitytype                 $item.username = $webapp.processmodel.username                 $item.password = $webapp.processmodel.password                  $obj = new-object psobject -property $item                 $list += $obj         }          $abc = ($list | %{$_.name+":"+ $_.applicatonpool+":"+$_.protocol+":"+$_.physicalpath}) -join "`n"         write-output "details default webapplication: `n $abc" >> c:\temp.txt         cd iis:\         $path ='sites\default web site\' + $website         $abcd = (get-webconfiguration -filter "system.webserver/security/authentication/*" -pspath $path | {$_.enabled -eq $true} | % {$_.sectionpath + ' :' + $_.location}) -join "`n" -replace "/system.webserver/security/authentication/",""         write-output " enable authentication mode given websites:`n $abcd" >> c:\temp.txt 

try run powershell script administrator, there no need import webadministration module