Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Powershell dealing with a range of computer names.

$
0
0

Hello all.  Abridged description, I'm a lab admin trying to re-write a VBS login script into Powershell.  I need to be able to run commands determined by computer name and number...for instance, I have complabA01 through complabA70.  01-25 need to do an action and copy a shared file, 26-40 need a different action and the same shared file, and 41-70 get a different action still and said shared file.  I've got the base code laid out and functional to determine the computer name and specific lines based on that:

$cn = $env:computername

If($cn -like 'complabA*'){do stuff}

If($cn -like 'complabB*'){do other stuff} so on. 

Is there a way go a layer deeper on that and say "if your number 01-25 do this"?  The problem well may be that I'm coming at this with slightly deeper roots in VBS... so I may well be over/under thinking this.

In case it'll help, in VBS we handle it by turning the numbers at the end of the name into a separate variable and using said secondary variable in a select case.

Any thoughts on how that can be done in Powershell?



Viewing all articles
Browse latest Browse all 15028

Trending Articles