powershell - 通过 Intune 使用 PScript 删除-VpnConnection
问题描述
我正在努力从 Endpoint Managed Windows 10 机器中删除未知的 VPN 配置。
最终用户没有本地管理员凭据。当我在登录用户上下文中运行脚本时,它会失败,因为他们无权删除 VPN 配置。当我将它作为系统运行时,脚本找不到任何配置。
是否可以像您很久以前那样以具有提升权限的用户身份临时运行脚本?
如果 UAC 是原因并且无法做到这一点,如何从没有本地管理员权限的用户远程删除未知 VPN 配置,而不将它们添加到本地管理员组,运行脚本,然后删除他们的权限?
这是脚本。
# Check to see what VPN connections exist on the computer, compare the names to a desired list of connections, and remove those not on the list
################################
# VARIABLES
$tempA = Get-VpnConnection -AllUserConnection # Retrieve all VPN Connections
$tempB = Get-VpnConnection # Retrieve all VPN Connections
$VPNConfigs = ("VPN_CONFIG_1","VPN_CONFIG_1","VPN_CONFIG_1","VPN_CONFIG_1") # The Configs that should stay
################################
foreach ($item in $tempA) {
If (!$VPNConfigs.Contains($item.Name))
{
Remove-VPNConnection -Name $item.Name -AllUserConnection -AsJob -Force
}
Else
{
End
}
}
foreach ($item in $tempB) {
If (!$VPNConfigs.Contains($item.Name))
{
Remove-VPNConnection -Name $item.Name -AsJob -Force
}
Else
{
Exit
}
}
谢谢
解决方案
推荐阅读
- python - 索引numpy矩阵
- excel - 用户窗体最小化时取消滚动
- swift - Swift:尝试访问数组中对象的值时出现错误
- cookies - 如何在 AspNet Core 中列出带有更改的 cookie
- nexus - 配置 helm 连接到 nexus
- swisscomdev - 在 Swisscom Application Cloud 上自动创建、恢复和下载 MongoDB 备份
- http - JMeter:我如何对随机 2 个浮点数求和
- laravel - npm 的新手 get SyntaxError: Unexpected token
- ios - Xcode 10 上的 iOS 模拟器崩溃
- php - WordPress CSRF 漏洞利用草案状态