From 615652182df0fdddc587792fa9ddfee6a9896a82 Mon Sep 17 00:00:00 2001 From: Ivo Oskamp Date: Thu, 19 Dec 2024 20:05:17 +0100 Subject: [PATCH] Upload files to "src/PWExpireNotification/1.0.1" --- .../1.0.1/PWExpireNotification-help.xml | 930 ++++++++++++++++++ .../1.0.1/PWExpireNotification.psd1 | 126 +++ .../1.0.1/PWExpireNotification.psm1 | 23 + 3 files changed, 1079 insertions(+) create mode 100644 src/PWExpireNotification/1.0.1/PWExpireNotification-help.xml create mode 100644 src/PWExpireNotification/1.0.1/PWExpireNotification.psd1 create mode 100644 src/PWExpireNotification/1.0.1/PWExpireNotification.psm1 diff --git a/src/PWExpireNotification/1.0.1/PWExpireNotification-help.xml b/src/PWExpireNotification/1.0.1/PWExpireNotification-help.xml new file mode 100644 index 0000000..f459155 --- /dev/null +++ b/src/PWExpireNotification/1.0.1/PWExpireNotification-help.xml @@ -0,0 +1,930 @@ + + + + + Get-PWADDSExpiringPassword + Get + PWADDSExpiringPassword + + This cmdlet obtains all users within the domain that have a password expiring at some point + + + + This cmdlet obtains all users within the domain that have a password expiring at some point and omits those users that have an empty passwordlastset attribute + + + + Get-PWADDSExpiringPassword + + ExpireInDays + + Filters the output to return only users with passwords that expire less than or equal to the day + + Object + + Object + + + None + + + ADFilter + + Allows the ability to scope query to a specific location or user attribute + + ScriptBlock + + ScriptBlock + + + None + + + IncludeAll + + Enables the return of all users even if the the password never expires. + + + SwitchParameter + + + False + + + + + + ADFilter + + Allows the ability to scope query to a specific location or user attribute + + ScriptBlock + + ScriptBlock + + + None + + + ExpireInDays + + Filters the output to return only users with passwords that expire less than or equal to the day + + Object + + Object + + + None + + + IncludeAll + + Enables the return of all users even if the the password never expires. + + SwitchParameter + + SwitchParameter + + + False + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> Get-PWADDSExpiringPassword + + Gets all users and their password expiration except if the user is disabled, ,the passwword is already expired, or the password is set to never expire. + + + + -------------------------- Example 1 -------------------------- + PS C:\> Get-PWADDSExpiringPassword -IncludeAll + + Gets all users and their password expiration except if the password less set is null. + + + + + + + + + Get-PWApplicationToken + Get + PWApplicationToken + + Obtains an Application token using a client secret + + + + Intended to be used to obtain an token for an application that has Mail.Send permissions within Graph. + + + + Get-PWApplicationToken + + clientID + + Application ID of the AAD application + + String + + String + + + None + + + clientSecret + + Client secret of the application + + String + + String + + + None + + + Resource + + Used to identify the graph resource where the token will be used. + + + https://graph.microsoft.com + https://graph.microsoft.us + https://dod-graph.microsoft.us + + String + + String + + + None + + + tenantName + + Full TenantName such as mydomain.onmicrosoft.com + + String + + String + + + None + + + + + + Resource + + Used to identify the graph resource where the token will be used. + + String + + String + + + None + + + clientID + + Application ID of the AAD application + + String + + String + + + None + + + clientSecret + + Client secret of the application + + String + + String + + + None + + + tenantName + + Full TenantName such as mydomain.onmicrosoft.com + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> $param = @{ + clientID = $clientID + clientSecret = $sec + resource = $resource + tenantName = $tenantName +} +$token = Get-PWApplicationToken @param + + Providing the client ID, secret, graph resource, and tenantname, returns an OAuth token for the specified application + + + + + + + + Send-PWExpiringMailMessage + Send + PWExpiringMailMessage + + Used to send password expiration notification of ADDS Users + + + + Used to send password expiration notification of ADDS Users + + + + Send-PWExpiringMailMessage + + ADAccount + + The ADUser account object + + PSObject + + PSObject + + + None + + + ExpireInDaysThreshold + + The threshold for limiting at what time a user would be notified based on when their password expires. + + Int32 + + Int32 + + + None + + + LogFile + + If you want to log each run of this function this will enable logging and display what users were notified placing the logfile in the specified path. + + String + + String + + + None + + + Logging + + Enable logging and output the logfile to the current working directory. + + + SwitchParameter + + + False + + + Resource + + The graph resource that will be used + + + https://graph.microsoft.com + https://graph.microsoft.us + https://dod-graph.microsoft.us + + String + + String + + + None + + + SendEmailAccount + + The account that will be used to send the mail message. e.g. Shared O365 Mailbox + + String + + String + + + None + + + Signature + + The signature as a string that you would like within your email body. + + String + + String + + + None + + + TestAddress + + Used for testing, all email messages will go to this address versus the end user. + + String + + String + + + None + + + TextToAdd + + A free form string that will be within the email message body below the default line containing the number of days remaining before their password expires. + + String + + String + + + None + + + Token + + The token that will be used to send the message + + String + + String + + + None + + + + + + ADAccount + + The ADUser account object + + PSObject + + PSObject + + + None + + + ExpireInDaysThreshold + + The threshold for limiting at what time a user would be notified based on when their password expires. + + Int32 + + Int32 + + + None + + + LogFile + + If you want to log each run of this function this will enable logging and display what users were notified placing the logfile in the specified path. + + String + + String + + + None + + + Logging + + Enable logging and output the logfile to the current working directory. + + SwitchParameter + + SwitchParameter + + + False + + + Resource + + The graph resource that will be used + + String + + String + + + None + + + SendEmailAccount + + The account that will be used to send the mail message. e.g. Shared O365 Mailbox + + String + + String + + + None + + + Signature + + The signature as a string that you would like within your email body. + + String + + String + + + None + + + TestAddress + + Used for testing, all email messages will go to this address versus the end user. + + String + + String + + + None + + + TextToAdd + + A free form string that will be within the email message body below the default line containing the number of days remaining before their password expires. + + String + + String + + + None + + + Token + + The token that will be used to send the message + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\>$params = @{ + Resource = $resource + SendEmailAccount = $SendEmailAccount + Token = $token + TestAddress = $TestAddress + ADAccount = $user + ExpireInDaysThreshold = $ExpireInDaysThreshold + TextToAdd = $TextToAddToEmail + Signature = $Signature + Logging = $true + + } + Send-PWExpiringMailMessage @params -Verbose + + This command takes the input from the $params hashtable and then sends an email to the test address versus the configured user. This would be used in a test scenario. Prior to live implemenation. + + + + + + + + Set-PWEmailBody + Set + PWEmailBody + + This cmdlet is used to configure the email message body in JSON format for configuring the JSON payload to graph + + + + This cmdlet is used to configure the email message body in JSON format for configuring the JSON payload to graph + + + + Set-PWEmailBody + + Subject + + Subject line of the email + + String + + String + + + None + + + Importance + + Set the Importance of the email: High or Low + + String + + String + + + None + + + Message + + The message body + + String + + String + + + None + + + EmailAddress + + Email address to receive the email + + String + + String + + + None + + + + + + EmailAddress + + Email address to receive the email + + String + + String + + + None + + + Importance + + Set the Importance of the email: High or Low + + String + + String + + + None + + + Message + + The message body + + String + + String + + + None + + + Subject + + Subject line of the email + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> Set-PWEmailBody -Subject "Your Password is Expiring in 10 Days" ` + -Importance "High" ` + -Message "Please change soon" ` + -EmailAddress "olduser@mycompany.com" + + Prepares the message section of the JSON payload to be submitted to Graph for sending the email message + + + + + + + + Set-PWEmailMessagePayload + Set + PWEmailMessagePayload + + Creates the full message paylod of to send to Graph API + + + + Creates the full message paylod of to send to Graph API + + + + Set-PWEmailMessagePayload + + ADAccount + + The account that is expiring + + PSObject + + PSObject + + + None + + + Signature + + Signature to be used within the email + + PSObject + + PSObject + + + None + + + TextToAdd + + Any additional text to add to the email body + + String + + String + + + None + + + + Set-PWEmailMessagePayload + + ADAccount + + The account that is expiring + + PSObject + + PSObject + + + None + + + Subject + + The email subject + + String + + String + + + None + + + + + + ADAccount + + The account that is expiring + + PSObject + + PSObject + + + None + + + Signature + + Signature to be used within the email + + PSObject + + PSObject + + + None + + + Subject + + The email subject + + String + + String + + + None + + + TextToAdd + + Any additional text to add to the email body + + String + + String + + + None + + + + + + None + + + + + + + + + + System.Object + + + + + + + + + + + + + + -------------------------- Example 1 -------------------------- + PS C:\> Set-PWEmailMessagePayload -TextToAdd $TextToAdd -ADAccount $ADAccount -Signature $Signature + + Prepares the json payload for graph + + + + + + \ No newline at end of file diff --git a/src/PWExpireNotification/1.0.1/PWExpireNotification.psd1 b/src/PWExpireNotification/1.0.1/PWExpireNotification.psd1 new file mode 100644 index 0000000..fb3bea7 --- /dev/null +++ b/src/PWExpireNotification/1.0.1/PWExpireNotification.psd1 @@ -0,0 +1,126 @@ +# +# Module manifest for module 'PSGet_ADDSPasswordNotification' +# +# Generated by: Daniel Carroll +# +# Generated on: 3/6/2022 +# + +@{ + +# Script module or binary module file associated with this manifest. +RootModule = 'PWExpireNotification.psm1' + +# Version number of this module. +ModuleVersion = '1.0.1' + +# Supported PSEditions +# CompatiblePSEditions = @() + +# ID used to uniquely identify this module +GUID = '626c48e4-dcf8-4364-b5ab-135429452403' + +# Author of this module +Author = 'Daniel Carroll' + +# Company or vendor of this module +CompanyName = 'Carroll Solutions' + +# Copyright statement for this module +Copyright = 'This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.' + +# Description of the functionality provided by this module +Description = 'PowerShell module for sending notifications to end users when their password is expiring using an O365 mailbox' + +# Minimum version of the Windows PowerShell engine required by this module +PowerShellVersion = '5.1' + +# Name of the Windows PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the Windows PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# DotNetFrameworkVersion = '' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# CLRVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +#RequiredModules = @('ActiveDirectory') + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = @('New-PWEmailBody','Get-PWApplicationToken','Get-PWADDSExpiringPassword','Send-PWExpiringMailMessage','New-PWEmailMessagePayload') + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = @() + +# Variables to export from this module +# VariablesToExport = @() + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = @() + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = @('ActiveDirectory','PasswordExpiration','EmailNotification','O365MailNotification','MicrosoftGraph','SendMail') + + # A URL to the license for this module. + LicenseUri = 'https://raw.githubusercontent.com/dacarroll/PWExpireNotification/main/LICENSE' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/dacarroll/PWExpireNotification' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + ReleaseNotes = 'Minor fix for New-PWEmailBody' + + # External dependent modules of this module + ExternalModuleDependencies = 'ActiveDirectory' + + } # End of PSData hashtable + +} # End of PrivateData hashtable + +# HelpInfo URI of this module + HelpInfoURI = 'https://github.com/dacarroll/PWExpireNotification/docs' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + diff --git a/src/PWExpireNotification/1.0.1/PWExpireNotification.psm1 b/src/PWExpireNotification/1.0.1/PWExpireNotification.psm1 new file mode 100644 index 0000000..77f202a --- /dev/null +++ b/src/PWExpireNotification/1.0.1/PWExpireNotification.psm1 @@ -0,0 +1,23 @@ +# .ExternalHelp PWExpireNotifictaion-help.xml +[cmdletbinding()] +param() +Write-Verbose $PSScriptRoot + +Write-Verbose 'Import everything in sub folders public, private folder' +$functionFolders = @('Functions', 'Internal') +ForEach ($folder in $functionFolders) { + $folderPath = Join-Path -Path $PSScriptRoot -ChildPath $folder + If (Test-Path -Path $folderPath) { + Write-Verbose -Message "Importing from $folder" + $functions = Get-ChildItem -Path $folderPath -Filter '*.ps1' + ForEach ($function in $functions) { + Write-Verbose -Message " Importing $($function.BaseName)" + try { + . $($function.FullName) + } + catch { + Write-Verbose ('Failed to import "{0}". Reason: "{1}"' -f $function.FullName, $_.Exception.Message) + } + } + } +} \ No newline at end of file