Advertisement
Guest User

Untitled

a guest
Jan 6th, 2018
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [CmdletBinding()]
  2. Param(
  3.     [Alias('Boss')]
  4.     [Parameter(Mandatory,Position=0)]
  5.     [Microsoft.ActiveDirectory.Management.ADUser]$Manager,
  6.  
  7.     [Alias('User')]
  8.     [Parameter(Mandatory,Position=1)]
  9.     [Microsoft.ActiveDirectory.Management.ADUser]$Employee,
  10.  
  11.     [Alias('ID','TrackingNo','Reference')]
  12.     [Parameter(Mandatory,Position=2)]
  13.     [uint32]$TrackingNumber,
  14.  
  15.     [Alias('Workstation','Machine','Computer')]
  16.     [Parameter(Mandatory,Position=3)]
  17.     [string]$ComputerName,
  18.  
  19.     [Alias('TicketID','TicketReference','Ticket')]
  20.     [Parameter(Mandatory,Position=4)]
  21.     [uint32]$TicketNumber,
  22.  
  23.     [Alias('NewEmail','CreateEmailAddress')]
  24.     [Parameter(Mandatory,Position=5,ParameterSetName='NewHire')]
  25.     [System.Net.Mail.MailAddress]$NewHireEmail,
  26.  
  27.     [Alias('InitializationText')]
  28.     [Parameter(Position=6,ParameterSetName='NewHire')]
  29.     [string]$NewHireText = "Default new hire text here.",
  30.  
  31.     [Alias('NewHirePassword','UserPassword')]
  32.     [Parameter(Position=7,ParameterSetName='NewHire')]
  33.     [securestring]$Password = (Read-Host -Prompt "Enter initial password for user:" -AsSecureString),
  34.  
  35.     [Alias('VanillaImage','VanillaImg','BaseImg')]
  36.     [Parameter(Mandatory,Position=5,ParameterSetName='BaseMigration')]
  37.     # Replace this type with appropriate type for whatever your input is supposed to be here
  38.     [PsObject]$BaseImage,
  39.  
  40.     [Alias('MoveEmail','MigrateEmail','MoveAddress','MigrateAddress')]
  41.     [Parameter(Mandatory,Position=6,ParameterSetName='BaseMigration')]
  42.     [System.Net.Mail.MailAddress]$MigrationEmailAddress,
  43.  
  44.     [Alias('MigrateText')]
  45.     [Parameter(Position=7,ParameterSetName='BaseMigration')]
  46.     [string]$MigrationText = "Default migration text here.",
  47.  
  48.     [Alias('CannedResponse')]
  49.     [Parameter(Position=8,ParameterSetName='NewHire')]
  50.     [Parameter(Position=8,ParameterSetName='BaseMigration')]
  51.     [string]$AutoReply = "Default autoreply text here."
  52. )
  53. Begin {
  54.     function Complete-AssetDeployment {
  55.         [CmdletBinding()]
  56.         Param(
  57.             # ???
  58.         )
  59.         # No idea what you're trying to do with this one yet. Try to define it more clearly.
  60.     }
  61.  
  62.     <#
  63.         This one's also up to you, as the specifics depend heavily on your environment.
  64.         The relevant help file(s) can be found here:
  65.         https://technet.microsoft.com/en-us/library/aa998225(v=exchg.160).aspx
  66.  
  67.         Specifically, you'll need to connect to a mailbox and use New-MailMessage
  68.         to create the email. Suggested script parameters are listed below.
  69.     #>
  70.     function New-AutomatedMailMessage {
  71.         [CmdletBinding()]
  72.         Param(
  73.             [Alias('To')]
  74.             [Parameter(Mandatory,Position=0)]
  75.             [ValidateNotNullOrEmpty()]
  76.             [System.Net.Mail.MailAddress[]]$Recipients,
  77.  
  78.             [Alias('Cc')]
  79.             [Parameter(Position=1)]
  80.             [System.Net.Mail.MailAddress[]]$CarbonCopies,
  81.  
  82.             [Alias('Bcc')]
  83.             [Parameter(Position=2)]
  84.             [System.Net.Mail.MailAddress[]]$BlindCarbonCopies,
  85.  
  86.             [Parameter(Position=3)]
  87.             [string]$Subject,
  88.  
  89.             [Alias('Message')]
  90.             [Parameter(Mandatory,Position=4)]
  91.             [string]$Body
  92.         )
  93.         # Function body goes here.
  94.     }
  95.  
  96.     function Reset-ADUserPassword {
  97.         [CmdletBinding()]
  98.         Param(
  99.             [Alias('Username','SamAccountName','Name')]
  100.             [Parameter(Mandatory,Position=0,ValueFromPipeline)]
  101.             [string]$Identity,
  102.  
  103.             [Alias('NewPassword')]
  104.             [Parameter(Position=1)]
  105.             [securestring]$Password = (Read-Host -Prompt "Enter initial password for user:" -AsSecureString),
  106.  
  107.             [Parameter(Position=2)]
  108.             [switch]$ChangeAtLogon
  109.         )
  110.         Set-ADAccountPassword -Identity $Identity -Reset -NewPassword $Password
  111.         Set-ADUser -Identity $Identity -ChangePasswordAtLogon ([bool]$ChangeAtLogon)
  112.     }
  113. }
  114. Process {
  115.     switch ($PSCmdlet.ParameterSetName) {
  116.         'NewHire' {
  117.             Write-Verbose "Performing New Hire functionality."
  118.             # Call appropriate functions with appropriate parameters and do whatever else you need to here
  119.         }
  120.         'BaseMigration' {
  121.             Write-Verbose "Performing Base Migration functionality."
  122.             # Same here, for the other purpose of the script
  123.         }
  124.     }
  125. }
  126. End {
  127.     <#
  128.         This section is for cleanup. Any remaining open connections, mailboxes, sockets, streams, etc.,
  129.         that need to be tidied up should be taken care of here and properly disposed of.
  130.     #>
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement