0
I'm a system admin at work and part of the day to day is creating new mailboxes for users in Office 365 and we are forced to use powershell to do this. The only variable in the PS commands is the user's email address however the script is split in two parts because we need to wait for some replication before completing the process.
So I would like to create a VB front end which I have designed but I don't know how to do the coding for it because I have no point of reference to copy if you see what I mean. This is my design which is very simple.
VB Design:
These are the PS commands I need to associate with the radio buttons;
Step 1
$credentials = get-credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://URL -Credential $credentials –AllowRedirection
Import-PSSession $Session
set-ADServerSettings -ViewEntireForest $true
Enable-RemoteMailbox -Identity test@test.com -RemoteRoutingAddress test@test.com.onmicrosoft.com
Enable-RemoteMailbox -Identity test@test.com -Archive
WAIT 3 HOURS
Step 2
$msolcred = get-credential
connect-msolservice -credential $msolcred
Set-MsolUser -UserPrincipalName test@test.com -UsageLocation GB
$LicOpt = New-MsolLicenseOptions -AccountSkuId company:STANDARDPACK -DisabledPlans MCOSTANDARD
Set-MsolUserLicense -UserPrincipalName test@test.com -AddLicenses company:STANDARDPACK -LicenseOptions $LicOpt
Remove-PSSession $Session
Questions about programming go on Stack Overflow, but I wouldn't be surprised if they already have an answer that would help you. – Ben N – 2016-05-29T21:51:04.013
1
you don't need a vb-frontend, you can do all of this in PowerShell. FoxDeploy has a perfect blog about it: https://foxdeploy.com/2015/04/10/part-i-creating-powershell-guis-in-minutes-using-visual-studio-a-new-hope/ go through all parts and you will have a nice, interactive GUI
– SimonS – 2016-05-29T21:55:58.357Thanks for tidying my post up DavidPostil I didn't know you could post it like that. – Daniel Neocleous – 2016-05-29T21:57:51.060
Thanks for the link Simon but I would like to learn how to make simple VB programs anyway as I have a domain join program I would liek to make but it's a little more complicated than this so I would like to cut my teeth on this one as it were. – Daniel Neocleous – 2016-05-29T21:59:00.277
@DanielNeocleous of course it's good to know VB, but for your task it wouldn't make sense. either you do everything in VB or everything in PowerShell. if you don't know VB, i would not make the effort to learn it. it's slowly growing old since GUI programming is now mostly done in C# and scripting in PowerShell on Windows Platforms. – SimonS – 2016-05-29T22:13:50.543
@SimonS I'm giving it a go as we speak but I'm not sure how you change which code runs depending on the selection from the radio buttons. – Daniel Neocleous – 2016-05-29T22:34:46.727
@DanielNeocleous -1 you're asking the wrong question and you should know you're asking the wrong question....basic programming, true of scripting too, is to break it down so you should ask how can you make it so that certian powershell commands run when you click a button. And you can look into writing a program that makes a Msgbox appear, then wait for 10 seconds, then a next msgbox appear.. so then you would learn how to use a timer too. that's what to ask and with those answers you can perhaps learn the skills to do your project – barlop – 2016-05-30T02:38:20.130