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 Dext 2 years, 8 months ago.
-
AuthorPosts
-
March 10, 2017 at 7:10 am #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
March 11, 2017 at 9:16 pm #271441Change 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.
March 13, 2017 at 6:17 am #379097Thanks 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.
March 13, 2017 at 2:10 pm #271442Oh, I see, you’re just echoing the path and not executing the script. Try this:
& “$PSScriptRootUserCreation.ps1″[/CODE][CODE]& “$PSScriptRootUserCreation.ps1″[/CODE]March 15, 2017 at 8:01 am #379100Slightly 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+” “+$Surnamewrite-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+” “+$Surnamewrite-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] -
AuthorPosts
You must be logged in to reply to this topic.