Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Calling New-PSSession from ASP.NET app fails (creates null object)
- param($serverName, $rootPath, $appsToInstall)
- $session = Enter-PsSession -ComputerName $serverName
- $command = {
- param($path,$apps)
- $pathtempIISsetup.ps1 $path $apps
- }
- $output = Invoke-Command -Session $session -scriptblock $command -ArgumentList
- $rootPath,$appsToInstall
- Remove-PSSession -Session $session
- using (Runspace remoteRunspace = RunspaceFactory.CreateRunspace())
- {
- remoteRunspace.Open();
- using (PowerShell ps = PowerShell.Create())
- {
- ps.Runspace = remoteRunspace;
- var cmd = new Command(Path.Combine(ServerPath, "LocalIISSetupLauncher.ps1"));
- cmd.Parameters.Add("serverName", this.Server.ServerName);
- cmd.Parameters.Add("rootPath", LocalIisDirectory);
- cmd.Parameters.Add("appsToInstall", Server.InstalledApplications.ToList().ToArray());
- ps.Commands.AddCommand(cmd);
- var results = ps.Invoke();
Add Comment
Please, Sign In to add comment