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

Jobs from Indeed

Powershell script

Powershell script

(OP)
Hi,

I am struggling with what should be an easy script, I need to map a user on a TS 2008 box to the connecting computers CD. The CD is shared and I can connect to it by running:

$net = $(New-Object -ComObject WScript.Network);
$net.MapNetworkDrive("e:", "\\PC\cd");

However, I want to do this automatically by using something like:

$net = $(New-Object -ComObject WScript.Network);
$net.MapNetworkDrive("e:", "\\%clientname%\cd");

Is there a %clientname% alternative in powershell that will work, or a better script?

Thanks in advance
 

RE: Powershell script

%computername%

http://www.samtechconsulting.com
_______________________________________
Great knowledge can be obtained by mastering the Google algorithm.

RE: Powershell script

I may have misread.

So the user is coming into a TS2008 server.  Then you want that user to map back to its local CD drive?

You can configure the redirection on the TS 2008 for clients, no script needed.

Or, I would utilize the clients RDP session to utilize local devices and resources.  I believe you can set this allowance on the TS side as well for all clients.  It may even let you specify the exact letter for the drive in question.

http://technet.microsoft.com/en-us/library/bb457106.aspx
 

http://www.samtechconsulting.com
_______________________________________
Great knowledge can be obtained by mastering the Google algorithm.

RE: Powershell script

By default, Terminal Services maps client drives automatically upon connection, including the CD-Rom

http://www.samtechconsulting.com
_______________________________________
Great knowledge can be obtained by mastering the Google algorithm.

RE: Powershell script

(OP)
%computername% will give you the name of the computer you are on with.

To make this a bit more difficult. We only want to give access to CD's for some users, so the RDP client brings nothing across with it.

hence the reason for doing this with a script/GPO

RE: Powershell script

(OP)
Thanks for all the input guys, to be honest I had never thought of using the "runthese programs after logon", but it worked a treat.

Thank you.

RE: Powershell script

Glad to help out!  :)

http://www.samtechconsulting.com
_______________________________________
Great knowledge can be obtained by mastering the Google algorithm.

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