INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Problem with remote execution

Problem with remote execution

(OP)
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 http://www.thespidersparlor.com/vbscript

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.

RE: Problem with remote execution

So, have you tried creating a PS session using

CODE --> PowerShell

$LyncSession = New-Pssession -Name "Lync" -ConnectionURI https://$LyncServer/ocspowershell/ -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.

RE: Problem with remote execution

(OP)
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 http://www.thespidersparlor.com/vbscript

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close