# Step #1: Retrieve a DLP policy named 'My DLP Policy'
$dlpPolicies = Get-DlpPolicy
$dlpPolicy = $dlpPolicies.value | where {$_.displayName -eq 'My DLP Policy'}
# Step #2: Get all Power Automate for desktop flow modules
$desktopFlowModules = Get-DesktopFlowModules
# Step #3: Convert the list of Power Automate for desktop flow modules to a format that can be added to the policy
$desktopFlowModulesToAddToPolicy = @()
foreach ($modules in $desktopFlowModules) {
$desktopFlowModulesToAddToPolicy += [pscustomobject]@{
id=$modules.id
name=$modules.Properties.displayName
type=$modules.type
}
}
# Step #4: Add all desktop flow modules to the 'blocked' category of 'My DLP Policy'
Add-ConnectorsToPolicy -Connectors $desktopFlowModulesToAddToPolicy -PolicyName $dlpPolicy.name -classification Blocked -Verbose
以下 PowerShell 指令碼可將兩個特定桌面流程模組新增至 DLP 原則的預設資料群組中。
# Step #1: Retrieve a DLP policy named 'My DLP Policy'
$dlpPolicies = Get-DlpPolicy
$dlpPolicy = $dlpPolicies.value | where {$_.displayName -eq 'My DLP Policy'}
# Step #2: Get all Power Automate for desktop flow modules
$desktopFlowModules = Get-DesktopFlowModules
# Step #3: Create a list with the 'Active Directory' and 'Workstation' modules
$desktopFlowModulesToAddToPolicy = @()
$activeDirectoryModule = $desktopFlowModules | where {$_.properties.displayName -eq "Active Directory"}
$desktopFlowModulesToAddToPolicy += [pscustomobject]@{
id=$activeDirectoryModule.id
name=$activeDirectoryModule.Properties.displayName
type=$activeDirectoryModule.type
}
$clipboardModule = $desktopFlowModules | where {$_.properties.displayName -eq "Workstation"}
$desktopFlowModulesToAddToPolicy += [pscustomobject]@{
id=$clipboardModule.id
name=$clipboardModule.Properties.displayName
type=$clipboardModule.type
}
# Step #4: Add both modules to the default data group of 'My DLP Policy'
Add-ConnectorsToPolicy -Connectors $desktopFlowModulesToAddToPolicy -PolicyName $dlpPolicy.name -Classification $dlpPolicy.defaultConnectorsClassification -Verbose
用於選擇退出桌面流程的 PowerShell 指令碼
如果您不想使用 DLP 桌面流程功能,您可以使用以下 PowerShell 指令碼選擇退出。
# Step #1: Retrieve the DLP policy named 'My DLP Policy'
$policies = Get-DlpPolicy
$dlpPolicy = $policies.value | Where-Object { $_.displayName -eq "My DLP Policy" }
# Step #2: Get all Power Automate for desktop flow modules
$desktopFlowModules = Get-DesktopFlowModules
# Step #3: Remove Desktop Flow modules from all 3 connector groups of the policy
foreach ($connectorGroup in $dlpPolicy.connectorGroups) {
$connectorGroup.connectors = $connectorGroup.connectors | Where-Object { $desktopFlowModules.id -notcontains $_.id }
}
# Step #4: Save the updated policy
Set-DlpPolicy -PolicyName $dlpPolicy.name -UpdatedPolicy $dlpPolicy