URL | index |
---|---|
0 |
Invoke-Automation Compliance module is designed as a framework for descibing rules in PowerShell and checking the compliance of these rules on specified objects.
Install IACompliance from the PowerShell Gallery using Install-Module
.
Install-Module -Name IACompliance
To generate a report you first need to describe Rule (IAComplianceRule) objects.
$rule1 = Rule 'Should start with capital letter' -For {
$Input[0].GetType().Name -like 'String'
} -Check {
$Input -cmatch '^[A-Z]'
}
Once you have one or more rules you can describe a check (IAComplianceCheck) object, wich defines what objects should comply with these rules.
$check1 = Check 'StringCheck' -This {
@('Test1','test2','Test 3','Test-4')
} -Against {
@(
$rule1,
Rule 'Should not contain any spaces' -For {
$Input[0].GetType().Name -like 'String'
} -Check {
$Input.IndexOf(' ') -lt 0
}
)
}
When you have described one or more checks you can combine these in a report using the Get-ComplianceReport cmdlet. By default this wil generate your report to the console but you can ask it to give back an IAComplianceReport object by using the -PassThru parameter.
Get-ComplianceReport -Name 'Alphanumeric Compliance Report' -Checks @(
$check1,
Check 'Number Check' -This {
@(2,3,5,12,2.4)
} -Against {
@(
Rule 'Should be an even number' -For {
$Input[0].GetType().Name -like 'Int32'
} -Check {
$Input % 2 -eq 0
}
)
}
) -PassTru
Submit a bug report via Issues
Awesome! Take a look at CONTRIBUTING.md
IACompliance is licensed under the MIT license.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.