Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with remote execution

Status
Not open for further replies.

markdmac

MIS
Dec 20, 2003
12,340
0
0
US
I am working on a project that preps some servers for MS Lync installation. I have created a VB.Net program that will generate a PS1 file based on the role a specific server will play. I need the contents of that file to execute on a remote server. The beginning of that PS1 file has the following:

Code:
Enter-PSSession SERVERNAME -Credential domain\username
Import-Module ServerManager -verbose
Add-WindowsFeature AS-NET-Framework -verbose
Add-WindowsFeature NET-Framework-Core -verbose
Add-WindowsFeature MSMQ-Server -verbose
Add-WindowsFeature MSMQ-Directory -verbose
Add-WindowsFeature PowerShell-ISE -verbose
Add-WindowsFeature Telnet-Client -verbose
Add-WindowsFeature FS-FileServer -verbose
Add-WindowsFeature SNMP-Service -verbose
Add-WindowsFeature SNMP-WMI-Provider -verbose
Add-WindowsFeature WAS-Process-Model -verbose
Add-WindowsFeature WAS-NET-Environment -verbose
Add-WindowsFeature WAS-Config-APIs -verbose
Exit-PSSession

The problem I am having is that the Add-WindowsFeature commands are executing locally rather than on the computer targeted int he remote session. Can anyone point me to what I am doing wrong?

I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
So, have you tried creating a PS session using
Code:
$LyncSession = New-Pssession -Name "Lync" -ConnectionURI [URL unfurl="true"]https://$LyncServer/ocspowershell/[/URL] -Credential $UserCredential
Import-PSSession $LyncSession -AllowClobber

to see if it's any different?

I've got a Lync prereq script as well. Curious to see how yours works out.

Do you have your Tek-Tips.com Swag? I've got mine!

Stop by the new Tek-Tips group at LinkedIn.
 
Yes, I had initially tried that. My issue is only with Windows 2008 R2. My VB.Net application launches PowerShell interactively just fine on a Windows 7 box but not on Windows 2008 R2.

This is driving me totally nuts. I discovered I needed to use Invoke-Command and use -ScriptBlock to be able to execute a script remotely. Apparently the session is for an interactive experience and not to launch scripts.

So, for whatever reason, VB.Net is able to launch PowerShell, but I can't get it to accept the file argument on 2008 R2, but the same code does pass the argument on Windows 7.


I hope that helps.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top