I need to make a conditional statement so that:
'.txt' { Invoke-CommandAndLog @((Get-ResourcePath "UtilityModules\LGPO.exe"), - " /un", $policy.FullName, " /q")}
It is based on both .txt and the filename of "xyz.txt". I am struggling to get this to work, though. Code below without additional condition of filename = xyz.txt
function Import-GpoSettings{
<#
.SYNOPSIS
Imports group policy files.
.DESCRIPTION
Applies DISA/ESS specific group policies.
.PARAMETER
Resource path to find pol files.
.PARAMETER
MatchString finds pol files that includes this string in the file name.
#>
Param (
[string] $Resource,
[string] $MatchString
)
$policies = Get-ChildItem (Get-ResourcePath $Resource) | Where-Object Extension -in '.txt', '.inf', '.csv' | Where-Object Name -match $matchString
ForEach ($policy in $policies) {
[string] $currentPolicy = $policy.BaseName
Write-HostAndLog "`t Applying standard $currentPolicy policy settings.`n"
switch ($policy.Extension) {
'.txt' { Invoke-CommandAndLog @((Get-ResourcePath "UtilityModules\LGPO.exe"), - " /un", $policy.FullName, " /q")}
'.txt' { Invoke-CommandAndLog @((Get-ResourcePath "UtilityModules\LGPO.exe"), " /t", $policy.FullName, " /q")}
'.inf' { Invoke-CommandAndLog @((Get-ResourcePath "UtilityModules\LGPO.exe"), " /s", $policy.FullName, " /q")}
'.csv' { Invoke-CommandAndLog @((Get-resourcepath "UtilityModules\LGPO.exe"), " /a", $policy.FullName, " /q")}
Default { }
}
}
}#endFunction
