As the title says, Create a "non-business" only policy and output the policy to CSV using PowerShell. I want to edit the "Group" column and assign this to an environment. (for only one environment) I will write the script code to be assigned after the image, I don't know what's wrong. By the way, it works if you set it to "AllEnviloments" instead of "SelectedEnviloments". ---------------------------------------------- # 新規作成するポリシーの名前を設定します $newDLPPolicyName = "TEST" # インポートするCSVのファイルパスを記入してください。 $inputCSVFilePath = "C:\PoewrShell_Policy\PS_TEST\PowerShellポリシー設定TEST用_本番環境_適用対象_20240318_inputs.csv" # 適用する環境のIDを指定します $environmentId = "67d90760-4e81-eb26-b629-9ac101f415bd" $newDLPPolicy = New-DlpPolicy -DisplayName $newDLPPolicyName -EnvironmentType "SelectedEnvironments" -EnvironmentId $environmentId $csv = Import-Csv -Path $inputCSVFilePath -Encoding UTF8 | Select Group, Name, ID, Type $allConnectors = $csv | Group-Object -Property Group $BusinessDataConnectors = $allConnectors | Where-Object { $_.Name -eq "BusinessDataGroup" } $NonBusinessDataConnectors = $allConnectors | Where-Object { $_.Name -eq "NonBusinessDataGroup" } $BlockedConnectors = $allConnectors | Where-Object { $_.Name -eq "BlockedGroup" } # [ビジネス] グループに割り当てるコネクタを定義します。 if($BusinessDataConnectors){ $BusinessDataConnectorsGroup = [PSCustomObject]@{ classification = "Confidential" connectors = $BusinessDataConnectors.Group | Select-Object Name, ID, Type } } else { $BusinessDataConnectorsGroup = [PSCustomObject]@{ classification = "Confidential" connectors = @() } } # [非ビジネス] グループに割り当てるコネクタを定義します。 if($NonBusinessDataConnectors){ $NonBusinessDataConnectorsGroup = [PSCustomObject]@{ classification = "General" connectors = $NonBusinessDataConnectors.Group | Select-Object Name, ID, Type } } else { $NonBusinessDataConnectorsGroup = [PSCustomObject]@{ classification = "General" connectors = @() } } # [ブロック] グループに割り当てるコネクタを定義します。 if($BlockedConnectors){ $BlockedConnectorsGroup = [PSCustomObject]@{ classification = "Blocked" connectors = $BlockedConnectors.Group | Select-Object Name, ID, Type } } else { $BlockedConnectorsGroup = [PSCustomObject]@{ classification = "Blocked" connectors = @() } } $allConnectorGroups = @() $allConnectorGroups += $BlockedConnectorsGroup $allConnectorGroups += $BusinessDataConnectorsGroup $allConnectorGroups += $NonBusinessDataConnectorsGroup $newDLPPolicy.connectorGroups = $allConnectorGroups Set-DlpPolicy -PolicyName $newDLPPolicy.name -UpdatedPolicy $newDLPPolicy ---------------------------------------------- "connectorGroups" の設定中に例外が発生しました: "このオブジェクトにプロパティ 'connectorGroups' が見つかりません。プロパティ が存在し、設定可能であることを確認してください。" 発生場所 C:\PoewrShell_Policy\PS_TEST\TEST.ps1:59 文字:1 + $newDLPPolicy.connectorGroups = $allConnectorGroups + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], SetValueInvocationException + FullyQualifiedErrorId : ExceptionWhenSetting Set-DlpPolicy : 引数が空の文字列であるため、パラメーター 'PolicyName' にバインドできません。 発生場所 C:\PoewrShell_Policy\PS_TEST\TEST.ps1:61 文字:27 + Set-DlpPolicy -PolicyName $newDLPPolicy.name -UpdatedPolicy $newDLPPo ... + ~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Set-DlpPolicy]、ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Set-DlpPolicy

Report
All responses (
Answers (