forked from bwya77/Master-User-Creator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Startup.pss
97 lines (74 loc) · 4.35 KB
/
Startup.pss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<File version="3.1">
<Code><![CDATA[#Define a Param block to use custom parameters in the project
#Param ($CustomParameter)
function Main {
<#
.SYNOPSIS
The Main function starts the project application.
.PARAMETER Commandline
$Commandline contains the complete argument string passed to the script packager executable.
.NOTES
Use this function to initialize your script and to call GUI forms.
.NOTES
To get the console output in the Packager (Forms Engine) use:
$ConsoleOutput (Type: System.Collections.ArrayList)
#>
Param ([String]$Commandline)
#--------------------------------------------------------------------------
$Global:Licenses2Add = New-Object 'System.Collections.Generic.List[System.Object]'
###REG KEYS
#Check if RegKey is present, if not then create one
$RegKey = Get-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator' -ErrorAction SilentlyContinue
if (! $RegKey)
{
#Create the root key
New-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator' -Force
New-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\TitleCase\AD' -Force
New-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\TitleCase\O365' -Force
New-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\UpperCase\AD' -Force
New-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\UpperCase\O365' -Force
New-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\LowerCase\AD' -Force
New-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\LowerCase\O365' -Force
}
$RegKeyReset = Get-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\Reset' -ErrorAction SilentlyContinue
if (! $RegKeyReset)
{
New-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\Reset' -Force
}
$PasswordSettings = (Get-ItemProperty 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\' | Get-ItemProperty -Name PasswordGen -ErrorAction SilentlyContinue).PasswordGen
If ($null -eq $PasswordSettings)
{
Get-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\' -Force | Set-ItemProperty -Name PasswordGen -Value 0 -Force | Out-Null
}
$UserFormatDisplayName = (Get-ItemProperty 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\' | Get-ItemProperty -Name UserFormatDisplayName -ErrorAction SilentlyContinue).UserFormatDisplayName
If ($null -eq $UserFormatDisplayName)
{
Get-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\' -Force | Set-ItemProperty -Name UserFormatDisplayName -Value "%FirstName% %Initial% %LastName%" -Force | Out-Null
}
$O365FormatDisplayName = (Get-ItemProperty 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\' | Get-ItemProperty -Name UserFormatO365DisplayName -ErrorAction SilentlyContinue).UserFormatO365DisplayName
If ($null -eq $UserFormatDisplayName)
{
Get-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\' -Force | Set-ItemProperty -Name UserFormatO365DisplayName -Value "%FirstName% %LastName%" -Force | Out-Null
}
$O365EmailFormatting = (Get-ItemProperty 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\' | Get-ItemProperty -Name UserFormatO365Email -ErrorAction SilentlyContinue).UserFormatO365Email
If (($O365EmailFormatting -eq $config) -or ($config -eq ""))
{
$config = "%FirstLetterFirstName%%LastName%%UserPrincipalNameDomain%"
Get-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\' -Force | Set-ItemProperty -Name UserFormatO365Email -Value $config -Force | Out-Null
}
#Thank you to user that has helped suggest items for v2
$Hill = (Get-ItemProperty 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\' | Get-ItemProperty -Name AHill -ErrorAction SilentlyContinue).AHill
If ($Hill -eq 1)
{
Add-Type -AssemblyName System.Windows.Forms
[System.Windows.Forms.MessageBox]::Show("Thank you Aaron Hill for all your ideas in improving this application, V2 wouldn't be as feature filled without all your ideas.", 'Thank You', 'OK')
Get-Item 'HKCU:\Software\TheLazyAdministrator\MasterUserCreator\' -Force | Set-ItemProperty -Name AHill -Value 0 -Force | Out-Null
}
#--------------------------------------------------------------------------
if((Show-MainForm_psf) -eq 'OK')
{
}
$script:ExitCode = 0 #Set the exit code for the Packager
}
]]></Code>
</File>