VB to Powershell help

We used to have a script that would run post create that would send out a email to notify certian people that a new users had been created.  we had a detailed VB script that did this, however since the upgrade to QC 5.0 this no longer is the case,  support says we need to run a power shell script in thew work flow section and in the "run-post sync script" area. This is what we had set up with the VB Script:

On Error Resume Next

' ********************************************************

' Access target user object and retrieve information

DirObj.GetInfo

DirObj.GetInfoEx "sAMAccountName",0

strLogon = DirObj.Get("sAMAccountName")

DirObj.GetInfo

DirObj.GetInfoEx "sn",0

strSn = DirObj.Get("sn")

DirObj.GetInfo

DirObj.GetInfoEx "givenName",0

strGivenName = DirObj.Get("givenName")

strPassword = Request.Get("edsaPassword")

DirObj.GetInfo

DirObj.GetInfoEx "edsvaParentCanonicalName",0

strOu = DirObj.Get("edsvaParentCanonicalName")

DirObj.GetInfo

DirObj.GetInfoEx "mail",0

strMail = DirObj.Get("mail")

DirObj.GetInfo

DirObj.GetInfoEx "Company",0

strCompany = DirObj.Get("Company")

DirObj.GetInfo

DirObj.GetInfoEx "Title",0

strTitle = DirObj.Get("Title")

Select Case strCompany

       Case "Ammon"

            strEMail = "user@d93.k12.id.us"

       Case "Bonneville HS"

            strEMail = "user@d93.k12.id.us"

       Case "Bridgewater"

            strEMail = "user@d93.k12.id.us"

       Case "Cloverdale"

            strEMail = "user@d93.k12.id.us"

       Case "Discovery"

            strEMail = "user@d93.k12.id.us"

       Case "Administration Building"

            strEMail = "user@d93.k12.id.us"         

       Case "Fairview"

            strEMail = "user@d93.k12.id.us"

       Case "Falls Valley"

            strEMail = "user@d93.k12.id.us"

       Case "Hillcrest HS"

            strEMail = "user@d93.k12.id.us"

       Case "Hillview"

            strEMail = "user@d93.k12.id.us"

       Case "Iona"

            strEMail = "user@d93.k12.id.us"

       Case "Lincoln HS"

            strEMail = "user@d93.k12.id.us"

       Case "Maintenance"

            strEMail = "user@d93.k12.us"

       Case "Mountain Valley"

            strEMail = "user@d93.k12.id.us"    

       Case "Rimrock"

            strEMail = "user@d93.k12.id.us"

       Case "Rocky Mountain"

            strEMail = "user@d93.k12.id.us"

       Case "Sandcreek"

            strEMail = "user@d93.k12.id.us"

       Case "Special Services"

            strEMail = "user@d93.k12.id.us"

       Case "Technology"

            strEMail = "user@d93.k12.id.us"

       Case "Telford"

            strEMail = "user@d93.k12.id.us"

       Case "Tiebreaker"

            strEMail = "user@d93.k12.id.us"

       Case "Transportation"

            strEMail = "user@d93.k12.id.us"

       Case "Ucon"

            strEMail = "user@d93.k12.id.us"

       Case "Woodland Hills"

            strEMail = "user@d93.k12.id.us"

       Case "Federal Programs"

            strEMail = "user@d93.k12.id.us"

       Case "Food Services"

            strEMail = "user@d93.k12.id.us"

       Case "Student Teachers"

            strEMail = "user@d93.k12.id.us"

       Case "Bonneville Virtual Academy"

            strEMail = "user@d93.k12.id.us"

End Select

' Set mail Constants and Variables

strCmdMailBCC = "user@d93.k12.id.us;user@d93.k12.id.us;user@d93.k12.id.us;user@d93.k12.id.us;user@d93.k12.id.us;user@d93.k12.id.us;user@d93.k12.id.us"

strCmdMailFrom = "postmaster@d93.k12.id.us"

strManagerMail = "user@d93.k12.id.us;user@d93.k12.id.us;user@d93.k12.id.us" & strEMail

constSmtpPort = 25

constSmtpServer = "172.18.0.25"

 

' set remaining mail data and call mail subroutine

strCmdMsgText = "User's First and Last name - " & StrGivenName & " " & strSn & vbCRLF & vbCRLF

strCmdMsgText = strCmdMsgText & "User Account Created - " & strLogon & vbCRLF & vbCRLF

strCmdMsgText = strCmdMsgText & "User's email address - " & strMail & vbCRLF & vbCRLF

strCmdMsgText = strCmdMsgText & "User's Password - " & strPassword & vbCRLF & vbCRLF

strCmdMsgText = strCmdMsgText & "User's Assigned School - " & strOu & vbCRLF & vbCRLF

strCmdMsgText = strCmdMsgText & "User's Job Title - " & strTitle

strCmdSubject = "New User Active Directory Account Created for " & strCompany

strCmdMailTo = strManagerMail

' copy the password to a field so it can be pulled in the password list

If (Not strPassword="") Then

    DirObj.put "employeeNumber", strPassword

    DirObj.setInfo

End If

* note I took all user names out of the script for posting reasons

This way we had one big script they way it would be done now is I would have a smaller script for each provsioning rule (which might be easier for me to maintain).

I just dont know how to convert this VB Scritpt in to a Power Shell Command.

I just dont want to re-invent the wheel if I dont have to.

Thanks in advance,

Lane

  • Open the VB project you want to use to run a PowerShell cmdlet. Right-click on the name of your project from the file directory on the upper right corner of your screen. Click on “Add Reference,” then click on the “Browse” button. Click on “System.Management.Automation.dll” and the “OK” button.