Looking to open different powershell script from current and close current

Home Forums Scripting PowerShell Looking to open different powershell script from current and close current

This topic contains 8 replies, has 3 voices, and was last updated by Avatar Dext 2 years, 8 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • Avatar
    5habbaranks
    Participant
    #166899

    Hi,
    Im currently building a menu based PowerShell script and thought its probably easier to call on other scripts rather than just having one continuous script which is a pain to see whats going on. After doing a little reading I thought I had it mastered but sadly not. Here is my code the running script is in the same directory as the script I am trying to call

    [FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$PSScriptRoot[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9]=[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]Split-Path[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#000080][FONT=Lucida Console][SIZE=1][COLOR=#000080][FONT=Lucida Console][SIZE=1][COLOR=#000080]-Parent[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#000080][FONT=Lucida Console][SIZE=1][COLOR=#000080][FONT=Lucida Console][SIZE=1][COLOR=#000080]-Path[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$MyInvocation[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9].[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]MyCommand[/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9].[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]Definition [/SIZE][/FONT][/SIZE][/FONT][/CODE]

    [CODE][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”AD Management Menu”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”Press 1: To Create A New User Account”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”Press 2: To Manage O365 Accounts”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”Press Q: To Quit”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$MM[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9]=[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]Read-Host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”Please Make Your Selection”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#00008b][FONT=Lucida Console][SIZE=1][COLOR=#00008b][FONT=Lucida Console][SIZE=1][COLOR=#00008b]Switch[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$MM[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]) {[/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]’1′[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] {[/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$PSScriptRoot[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9]+[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”UserCreation.ps1″[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]}[/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]’2′[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] { [/SIZE][/FONT][/SIZE][/FONT]
    [/CODE]

    Is it obvious what Im doing incorrectly? Thanks[CODE]$PSScriptRoot = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition [/CODE]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”AD Management Menu”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”Press 1: To Create A New User Account”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”Press 2: To Manage O365 Accounts”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”Press Q: To Quit”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$MM[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9]=[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]Read-Host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”Please Make Your Selection”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#00008b][FONT=Lucida Console][SIZE=1][COLOR=#00008b][FONT=Lucida Console][SIZE=1][COLOR=#00008b]Switch[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$MM[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]) {[/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]’1′[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] {[/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$PSScriptRoot[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9]+[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”UserCreation.ps1″[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]}[/SIZE][/FONT][/SIZE][/FONT]
    [FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]’2′[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] { [/SIZE][/FONT][/SIZE][/FONT]
    [/CODE]

    Is it obvious what Im doing incorrectly? Thanks[CODE]write-host “++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”

    write-host “AD Management Menu”
    write-host
    write-host “Press 1: To Create A New User Account”
    write-host “Press 2: To Manage O365 Accounts”
    write-host “Press Q: To Quit”
    write-host
    write-host
    write-host
    write-host “++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”

    $MM = Read-Host “Please Make Your Selection”
    Switch ($MM) {
    ‘1’ {
    $PSScriptRoot+“UserCreation.ps1”
    }
    ‘2’ {
    [/CODE]

    Is it obvious what Im doing incorrectly? Thanks

    JeremyW
    JeremyW
    Moderator
    #271441

    Change your $PSScriptRoot variable to this:
    $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path[/CODE]

    See if that fixes it for you. [CODE]$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path[/CODE]

    See if that fixes it for you.

    Avatar
    Dext
    Member
    #379097

    Thanks but it didn’t open the other script I was after it just sits in the current “do” loop as below

    [FONT=Lucida Console][SIZE=1][COLOR=#00008b][FONT=Lucida Console][SIZE=1][COLOR=#00008b][FONT=Lucida Console][SIZE=1][COLOR=#00008b]do[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]{[/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”AD Management Menu”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”Press 1: To Create A New User Account”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”Press 2: To Manage O365 Accounts”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”Press Q: To Quit”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]write-host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$MM[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9]=[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]Read-Host[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”Please Make Your Selection”[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#00008b][FONT=Lucida Console][SIZE=1][COLOR=#00008b][FONT=Lucida Console][SIZE=1][COLOR=#00008b]Switch[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$MM[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]) {[/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]’1′[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] {[/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$PSScriptRoot[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9]=[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]Split-Path[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$MyInvocation[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9].[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]MyCommand[/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9].[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]Path[/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$PSScriptRoot[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9]+[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]”UserCreation.ps1″[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]}[/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]’2′[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] {[/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]Set-ExecutionPolicy[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8a2be2][FONT=Lucida Console][SIZE=1][COLOR=#8a2be2][FONT=Lucida Console][SIZE=1][COLOR=#8a2be2]RemoteSigned[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$credential[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9]=[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]Get-Credential[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]Import-Module[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8a2be2][FONT=Lucida Console][SIZE=1][COLOR=#8a2be2][FONT=Lucida Console][SIZE=1][COLOR=#8a2be2]MSOnline[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]Connect-MsolService[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#000080][FONT=Lucida Console][SIZE=1][COLOR=#000080][FONT=Lucida Console][SIZE=1][COLOR=#000080]-Credential[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$credential[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]}[/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]’Q'[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] {[/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#00008b][FONT=Lucida Console][SIZE=1][COLOR=#00008b][FONT=Lucida Console][SIZE=1][COLOR=#00008b]return[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]}[/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]}[/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1]}[/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#00008b][FONT=Lucida Console][SIZE=1][COLOR=#00008b][FONT=Lucida Console][SIZE=1][COLOR=#00008b]until[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] ([/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500][FONT=Lucida Console][SIZE=1][COLOR=#ff4500]$MM[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9][FONT=Lucida Console][SIZE=1][COLOR=#a9a9a9]-eq[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1] [/SIZE][/FONT][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000][FONT=Lucida Console][SIZE=1][COLOR=#8b0000]’Q'[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Lucida Console][SIZE=1][FONT=Lucida Console][SIZE=1])[/SIZE][/FONT][/SIZE][/FONT]

    [FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff][FONT=Lucida Console][SIZE=1][COLOR=#0000ff]cls [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
    [/CODE]

    The script I am trying to call is in the same directory as the running script.[CODE]do

    {

    write-host “++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”

    write-host “AD Management Menu”

    write-host

    write-host “Press 1: To Create A New User Account”

    write-host “Press 2: To Manage O365 Accounts”

    write-host “Press Q: To Quit”

    write-host

    write-host

    write-host

    write-host “++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”

    $MM = Read-Host “Please Make Your Selection”

    Switch ($MM) {

    ‘1’ {

    $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path

    $PSScriptRoot+“UserCreation.ps1”

    }

    ‘2’ {

    Set-ExecutionPolicy RemoteSigned

    $credential = Get-Credential

    Import-Module MSOnline

    Connect-MsolService -Credential $credential

    }

    ‘Q’ {

    return

    }

    }

    }

    until ($MM -eq ‘Q’)

    cls
    [/CODE]

    The script I am trying to call is in the same directory as the running script.

    JeremyW
    JeremyW
    Moderator
    #271442

    Oh, I see, you’re just echoing the path and not executing the script. Try this:
    & “$PSScriptRootUserCreation.ps1″[/CODE][CODE]& “$PSScriptRootUserCreation.ps1″[/CODE]

    Avatar
    Dext
    Member
    #379099

    Bingo – thanks worked a treat :)

    JeremyW
    JeremyW
    Moderator
    #271446

    Glad to help. 8)

    Avatar
    Dext
    Member
    #379100

    Slightly different situation but… If I have a switch statement and then halfway through that switch statement I have another switch statement and then want to finish off the previous switch statement – is this possible? Or should I be going about it differently? As currently it seems to jump out of the switch Im in

    write-host “++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
    write-host “AD User Management Menu”
    write-host
    write-host “Press 1: To Create Local User Account”
    write-host “Press 2: To Link User to O365”
    write-host “Press 3: To Disable A User Account”
    write-host “Press Q: To Quit”
    write-host
    write-host
    write-host
    write-host “++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
    $UM1 = Read-Host “Please Make Your Selection”

    Switch ($UM1) {

    ‘1’ {
    {

    $FirstName = Read-Host “Please specify the users First name”
    $Surname = Read-Host “Please specify users Surname”
    $Username = $Firstname+”.”+ $Surname
    $SamAccountName = $Username
    $DisplayName = $Firstname+” “+$Surname

    write-host “++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
    write-host ‘Site’
    write-host
    Write-Host ‘1. Site A’
    Write-Host ‘2. Site B’
    write-host
    write-host
    write-host “++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
    $DV1 = Read-Host “Please select the site for this user”

    #+++++++++++++++++++++++++++++++++++++++++++++#
    # Site Section #
    # #
    #+++++++++++++++++++++++++++++++++++++++++++++#

    Switch ($DV1) {
    ‘1’
    {
    $UserEmail = $Username+”@Domain.com”
    $wwwHomePage = “www.Domain.com”
    [/CODE][CODE]write-host “++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
    write-host “AD User Management Menu”
    write-host
    write-host “Press 1: To Create Local User Account”
    write-host “Press 2: To Link User to O365”
    write-host “Press 3: To Disable A User Account”
    write-host “Press Q: To Quit”
    write-host
    write-host
    write-host
    write-host “++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
    $UM1 = Read-Host “Please Make Your Selection”

    Switch ($UM1) {

    ‘1’ {
    {

    $FirstName = Read-Host “Please specify the users First name”
    $Surname = Read-Host “Please specify users Surname”
    $Username = $Firstname+”.”+ $Surname
    $SamAccountName = $Username
    $DisplayName = $Firstname+” “+$Surname

    write-host “++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
    write-host ‘Site’
    write-host
    Write-Host ‘1. Site A’
    Write-Host ‘2. Site B’
    write-host
    write-host
    write-host “++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++”
    $DV1 = Read-Host “Please select the site for this user”

    #+++++++++++++++++++++++++++++++++++++++++++++#
    # Site Section #
    # #
    #+++++++++++++++++++++++++++++++++++++++++++++#

    Switch ($DV1) {
    ‘1’
    {
    $UserEmail = $Username+”@Domain.com”
    $wwwHomePage = “www.Domain.com”
    [/CODE]

    Avatar
    Dext
    Member
    #379101

    Managed to sort it with an IF statement :)

    JeremyW
    JeremyW
    Moderator
    #271448

    You should be able to do a switch within a switch. The code you posted looks incomplete. But glad you got it sorted. :)

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.