Upload files to "Examples"
This commit is contained in:
		
							parent
							
								
									b566a71484
								
							
						
					
					
						commit
						aac501ac89
					
				
							
								
								
									
										47
									
								
								Examples/SendMailMessage.ps1
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								Examples/SendMailMessage.ps1
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,47 @@ | |||||||
|  | [cmdletbinding()] | ||||||
|  | param ( | ||||||
|  |     $CredentialPath = '', | ||||||
|  |     $clientID = '', | ||||||
|  |     $resource = 'https://graph.microsoft.com', | ||||||
|  |     $tenantName = '', | ||||||
|  |     $SendEmailAccount = '', | ||||||
|  |     $TestAddress = '', | ||||||
|  |     $TextToAddToEmail = "To change your password on a PC press CTRL ALT Delete and choose Change Password", | ||||||
|  |     $Signature = "Jolly B. Admin", | ||||||
|  |     $Logging = $true, | ||||||
|  |     $ExpireInDaysThreshold = 39 | ||||||
|  | ) | ||||||
|  | 
 | ||||||
|  | #Token | ||||||
|  | $sec = (Import-Clixml -Path $CredentialPath).GetNetworkCredential().Password | ||||||
|  | 
 | ||||||
|  | $param = @{ | ||||||
|  |     clientID     = $clientID | ||||||
|  |     clientSecret = $sec | ||||||
|  |     resource     = $resource | ||||||
|  |     tenantName    = $tenantName | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | $token = Get-PWApplicationToken @param | ||||||
|  | 
 | ||||||
|  | #Get all users | ||||||
|  | 
 | ||||||
|  | if ($token) { | ||||||
|  |     $ListOfUsers = Get-PWADDSExpiringPassword | ||||||
|  |     Write-Verbose ("User Account: {0}, ExpiresOn: {1}, Days: {2} " -f $ListOfUsers[0].Name, $ListOfUsers[0].PasswordExpiresOn, $ListOfUsers[0].PasswordDaystoExpire) | ||||||
|  |     foreach ($user in $ListOfUsers[0]) { | ||||||
|  |         $params = @{ | ||||||
|  |             Resource              = $resource | ||||||
|  |             SendEmailAccount      = $SendEmailAccount | ||||||
|  |             Token                 = $token | ||||||
|  |             TestAddress           = $TestAddress | ||||||
|  |             ADAccount             = $user | ||||||
|  |             ExpireInDaysThreshold = $ExpireInDaysThreshold | ||||||
|  |             TextToAdd             = $TextToAddToEmail | ||||||
|  |             Signature             = $Signature | ||||||
|  |             Logging               = $true | ||||||
|  |              | ||||||
|  |         } | ||||||
|  |         Send-PWExpiringMailMessage @params -Verbose | ||||||
|  |     } | ||||||
|  | }   | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user