This commit is contained in:
Przemyslaw Klys
2020-06-28 10:08:09 +02:00
parent 27bd83eaba
commit 97ffc8bfd5
12 changed files with 154 additions and 67 deletions
+77
View File
@@ -0,0 +1,77 @@
$SecurityOptions = @{
Category = 'SecuritySettings'
Settings = 'SecurityOptions'
# This is to make sure we're not loosing anything
# We will detect this and if something is missing provide details
PossibleProperties = @(
'KeyName'
'SettingNumber'
'Display'
'SystemAccessPolicyName'
'SettingString'
)
Translate = [ordered] @{
'KeyName' = 'KeyName'
'KeyDisplayName' = 'Display', 'Name'
'KeyDisplayUnits' = 'Display', 'Units'
'KeyDisplayBoolean' = 'Display', 'DisplayBoolean'
'KeyDisplayString' = 'Display', 'DisplayString'
'SystemAccessPolicyName' = 'SystemAccessPolicyName'
'SettingString' = 'SettingString'
'SettingNumber' = 'SettingNumber'
}
Types = [ordered] @{
'KeyDisplayBoolean' = { try { [bool]::Parse($args) } catch { $null } }
}
}
$LugsSettingsLocalUsersAndGroups = @{
PossibleProperties = @(
'clsid'
'Group'
'User'
)
CustomCode = {
}
<#
LoopOver = @{
User = @{
}
Group = @{
}
}
#>
<#
Translate = [ordered] @{
Name = #= $Entry.name
Changed = #= [DateTime] $Entry.changed
GPOSettingOrder = #= $Entry.GPOSettingOrder
Filters = #= $Entry.Filters
ActionType = #= $NestedType
Action = #= $Entry.Properties.Action
UserName = #= $Entry.Properties.userName
NewName = #= $Entry.Properties.newName
Description = #= $Entry.Properties.description
DeleteAllUsers = #= [bool] $Entry.Properties.deleteAllUsers
DeleteAllGroups = #= [bool] $Entry.Properties.deleteAllGroups
RemoveAccounts = #= [bool] $Entry.Properties.removeAccounts
GroupSid = #= $Entry.Properties.groupSid
GroupName = #= $Entry.Properties.groupName
MembersName = #= $Member.Name
MembersAction = #= $Member.Action
MembersSid = #= $Member.Sid
FullName = #= $Entry.Properties.fullName
AccountCpassword = #= $Entry.Properties.cpassword
AccountChangeLogon = #= [bool] $Entry.Properties.changeLogon
AccountNoChange = #= [bool] $Entry.Properties.noChange
AccountNeverExpires= #= [bool] $Entry.Properties.neverExpires
AccountDisabled = #= [bool] $Entry.Properties.acctDisabled
SubAuthority = #= $Entry.Properties.subAuthority
}
#>
}
@@ -1,24 +0,0 @@
$SecuritySettingsSecurityOptions = @{
# This is to make sure we're not loosing anything
# We will detect this and if something is missing provide details
PossibleProperties = @(
'KeyName'
'SettingNumber'
'Display'
'SystemAccessPolicyName'
'SettingString'
)
Translate = [ordered] @{
'KeyName' = 'KeyName'
'KeyDisplayName' = 'Display', 'Name'
'KeyDisplayUnits' = 'Display', 'Units'
'KeyDisplayBoolean' = 'Display', 'DisplayBoolean'
'KeyDisplayString' = 'Display', 'DisplayString'
'SystemAccessPolicyName' = 'SystemAccessPolicyName'
'SettingString' = 'SettingString'
'SettingNumber' = 'SettingNumber'
}
Types = [ordered] @{
'KeyDisplayBoolean' = { try { [bool]::Parse($args) } catch { $null } }
}
}
+6 -5
View File
@@ -2,6 +2,7 @@
[cmdletBinding()]
param(
[System.Collections.IDictionary] $InputData,
[string] $Report,
[string] $Category,
[string] $Settings
)
@@ -15,7 +16,7 @@
$AllProperties = Select-Properties -AllProperties -Objects $InputData.$Category.$Settings
$MissingProperties = $AllProperties | Where-Object { $_ -notin 'DisplayName', 'DomainName', 'GUID', 'Linked', 'LinksCount', 'Links', 'GPOType', 'GPOCategory', 'GPOSettings' }
foreach ($Property in $MissingProperties) {
if ($Property -notin $Script:GPODitionary[$Category][$Settings]['PossibleProperties']) {
if ($Property -notin $Script:GPODitionary[$Report]['PossibleProperties']) {
Write-Warning "Invoke-Translation - We're missing property for $Category / $Settings - $Property"
}
}
@@ -33,9 +34,9 @@
}
# Lets loop thru each Translate Property
foreach ($PropertyName in $Script:GPODitionary[$Category][$Settings]['Translate'].Keys) {
foreach ($PropertyName in $Script:GPODitionary[$Report]['Translate'].Keys) {
# We get property that we expect on our $GPOEntry object
$Property = $Script:GPODitionary[$Category][$Settings]['Translate'][$PropertyName]
$Property = $Script:GPODitionary[$Report]['Translate'][$PropertyName]
# Since it's possible we may be interested in something that is a nested property we need to do some looping into the object
$Value = $GPOEntry
@@ -44,9 +45,9 @@
}
# Now we simply assing that value to new GPO Entry
# But before we do so, we need to check if it has required type
if ($Script:GPODitionary[$Category][$Settings]['Types'][$PropertyName]) {
if ($Script:GPODitionary[$Report]['Types'][$PropertyName]) {
# This basically checks in dictionary if we want to convert the type from a string to lets say boolean or something else
$CreateGPO["$PropertyName"] = Invoke-Command -Command $Script:GPODitionary[$Category][$Settings]['Types'][$PropertyName] -ArgumentList $Value
$CreateGPO["$PropertyName"] = Invoke-Command -Command $Script:GPODitionary[$Report]['Types'][$PropertyName] -ArgumentList $Value
} else {
$CreateGPO["$PropertyName"] = $Value
}
+4 -3
View File
@@ -1,5 +1,6 @@
$Script:GPODitionary = @{
SecuritySettings = @{
SecurityOptions = $SecuritySettingsSecurityOptions
}
SecurityOptions = $SecurityOptions
#LugsSettings = @{
# LocalUsersAndGroups = $LugsSettingsLocalUsersAndGroups
}