Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Use -match results to run script

$
0
0

Hi guys,

I want to create a PowerShell script that when run will get the computer name and depending if certain variables in the computer name are present will run a .vbs script that exists on a network share. If the variable in the pc name is not present the script just needs to close silently, no notifications are required.

So far I have the below code which get's the computer name and defines it as a variable. I have got the true / false function working also. I'm just stuck on the run the script if true part.

$computer = gc env:computername

$computer -match "part of the pc name"

Thanks in advance, I'm completely new to coding / PowerShell and any help is much appreciated!

Cheers,

Joe 


Viewing all articles
Browse latest Browse all 6937

Trending Articles