Jump to content

Recommended Posts

Wondering if anyone has any suggestions.

I need to create a script that compares @‌ComputerName to a string variable that contains "IT-"... I have looked at things such as StringSplit and trying a String Parsing... but it doesn't seem to meet what I want. (I could be doing it totally wrong)

Here is some generic code of what I am trying to do.

$sVariable = "IT-"

If @ComputerName = $sVariable Then
   MsgBox(0, "Success!", "Blah Blah Blah")
Else
   MsgBox(0, "Fail!", "Blah Blah Blah")
EndIf

I guess, what I am needing help on, is the "middle" piece that compares the users @ComputerName to my $sVariable?

Share this post


Link to post
Share on other sites

Thanks! So, if I used StringLeft I would do something like...

Local $sString = StringLeft("IT-Blah, 3) essentially, anything after the IT- is of no matter, I just need to confirm that the computername starts with IT-

If @ComputerName = $sString Then
   MsgBox(0, "Success!", "Blah Blah Blah")
Else
   MsgBox(0, "Fail!", "Blah Blah Blah")
EndIf

Share this post


Link to post
Share on other sites

Yup, and use code tags.  they are the icon to the left of the smiley.  And here it is ternary.

$sString = "IT-"
$sResult = stringleft(@ComputerName , 3) = $sString ? "Success!" : "Fail!"
msgbox(0, '' , $sResult)

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...