Hi,
I’m new to the forum so please excuse me if this is a commonly asked question. I carried out some searches but could not find the answers I need.
Is it possible to set certain parameters as global within a module?
Example:
param(
[String]$SearchBase = "OU=Domain Users,DC=myOrg,DC=com",
[Switch]$CreateReport
)
function createReport {
if($CreateReport) {
Write-Host "Creating a report"
}
}
function Get-InactiveAccounts{
param(
[int32]$Days = 30
)
adminCheck
Search-ADAccount `
-SearchBase $SearchBase `
-AccountInactive -UsersOnly -TimeSpan "$days" |
Where-Object {$_.Enabled -eq $True } |
Sort-Object Name |
Select-Object Name,`
@{Name='Username';Expression={$_.SamAccountName}},`
LastLogonDate
createReport
}
What I’m trying to achieve is have a parameter option for all functions in the module called CreateReport, however I am only getting the parameter Days which I’ve created local to the function.
Is this something that is possible within the module? Or should I be looking at another way of doing it?
Any help will be greatly appreciated!