Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

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

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

bobsa32 (TechnicalUser) (OP)
1 Jul 11 3:34
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
 
TechyMcSe2k (TechnicalUser)
1 Jul 11 9:52
%computername%

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

TechyMcSe2k (TechnicalUser)
1 Jul 11 10:04
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.

TechyMcSe2k (TechnicalUser)
1 Jul 11 10:14
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.

bobsa32 (TechnicalUser) (OP)
1 Jul 11 10:38
%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
58sniper (MIS)
1 Jul 11 15:23
As an FYI, there is a PowerShell forum at forum1619: PowerShell (Microsoft).

Also, in PowerShell, you can access environment variables using $env:<variable>

such as
$env:computername

Stop by the new Tek-Tips group at LinkedIn. Come say hi, look for a job, have some fun. http://www.linkedin.com/groups/Networking-TekTipscom-forums-members-3952395

Pat Richard MVP
http://www.exchangeblogs.com/
 

TechyMcSe2k (TechnicalUser)
1 Jul 11 15:36
Someone else had the same isue....sort of :)  Try this
RE:I had to put the script in "Run these programs after logon" in GPO...
http://social.technet.microsoft.com/Forums/en-US/winserverTS/thread/28a079d6-0e53-4431-b60b-1467817fb230

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

bobsa32 (TechnicalUser) (OP)
2 Jul 11 3:35
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.
TechyMcSe2k (TechnicalUser)
5 Jul 11 11:42
Glad to help out!  :)

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

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!

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