Articles of PowerShell

通过Powershell从Windowsregistry项中删除ACL

我正在尝试创build一个可以通过GPO分发到笔记本电脑(运行64位Windows 7 Professional)的启动脚本,以使任何用户(包括本地pipe理员)都无法显示连接的无线networking的密码。 我已经做了大部分,但不知道如何从密钥的安全条目中删除用户/组。 这是我到目前为止,它基本上定义variables并将密钥的所有权更改为本地“pipe理员”组。 $hkey = "HKEY_CLASSES_ROOT\AppID\{86F80216-5DD6-4F43-953B-35EF40A35AEE}" $exe = "\\server\share\SetACL.exe" & $exe -on $hkey -ot reg -actn setowner -ownr n:'Administrators' 脚本的最终结果应该从安全条目中删除“BUILTIN \ Administrators”,“BUILTIN \ Users”,“SERVICE \ TrustedInstaller”, 只保留具有读取权限的“BUILTIN \ SYSTEM” ,然后从SYSTEM获取权限并给予它们到BUILTIN \ Administrators。 这个configuration已经过testing和工作。 为了使用get-acl,你必须将ps-drive映射到hkcrconfiguration单元(因为它是一个指向{hklm,hkcu} \ SOFTWARE \ Classes的别名),所以我有这个,如果get-acl甚至需要删除权限: New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT $dkey = "HKCR:\AppID\{86F80216-5DD6-4F43-953B-35EF40A35AEE}" $acl = get-acl $dkey 我在互联网上发现了很多有关添加拒绝权限的信息,但是我不想添加拒绝信息,我只想删除条目,就好像点击属性>安全性中的“删除”一样。 […]

远程login到Exchange 2016configuration时缺lessCore PowerShell命令

我遇到了一个问题,即在远程login到Exchange 2016服务器时,不存在简单的命令(例如Get-Module)。 我正在运行的命令是: Invoke-Command -ConfigurationName Microsoft.Exchange -ConnectionUri http://SERVERNAME/powershell -Authentication Kerberos -Credential $cred -ScriptBlock { Get-Module } 结果是: The term 'Get-Module' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try […]

Set-AzureRmAutomationModule无法find自动化帐户

我正尝试将自定义DSC模块上传到我们的Azure自动化帐户。 C:\Code\Epitec DSC [master ≡ +1 ~1 -1 !]> Set-AzureRmAutomationModule -Name "WindowsUpdate" -ContentLinkUri "{ContentURL}.zip" -ResourceGroupName "OI-Default-East-US" -AutomationAccountName "Epitec-Automation" -Verbose Set-AzureRmAutomationModule : The Automation account was not found. At line:1 char:1 + Set-AzureRmAutomationModule -Name "WindowsUpdate" -ContentLinkUri "ht … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Set-AzureRmAutomationModule], ArgumentException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.SetAzureAutomationModule 运行命令Get-AzureRmAutomationAccount我能够获得自动化帐户 C:\Code\Epitec DSC [master ≡ […]

Register-ClusteredScheduledTask:参数不正确

当执行下面的Register-ClusteredScheduledTask我得到这个错误。 Register-ClusteredScheduledTask -TaskName $ ClusterTaskName -TaskType AnyNode -Xml $ TaskXML | 外空 Register-ClusteredScheduledTask : The parameter is incorrect. At C:\Setup-Scheduler.ps1:215 char:5 + Register-ClusteredScheduledTask -TaskName $ClusterTaskName -TaskT … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo: InvalidArgument: (PS_ClusteredScheduledTask:Root/Microsoft/…ed ScheduledTask) [Register-ClusteredScheduledTask], CimException + FullyQualifiedErrorId: HRESULT 0x80070057,Register-ClusteredScheduledTask 我的XML <?xml version="1.0" encoding="UTF-16"?> <Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> <RegistrationInfo /> <Triggers> <TimeTrigger> <Repetition> <Interval>PT15M</Interval> <StopAtDurationEnd>false</StopAtDurationEnd> </Repetition> […]

为什么我可以用icals设置所有权,但是不能设置-acl在2K12R2上?

为什么使用get-acl -Path 'C:\Program Files' | set-acl -Path 'D:\Program Files' get-acl -Path 'C:\Program Files' | set-acl -Path 'D:\Program Files'以pipe理员get-acl -Path 'C:\Program Files' | set-acl -Path 'D:\Program Files'身份告诉我,我不允许在使用icACLs "C:\Program Files" /save Perms.txt然后icACLs D:\ /restore Perms.txt工作没有错误?

DSC环境资源WMF5.1后不再工作 – 不检测PATH值?

我有一些使用环境资源设置path值的部分DSC脚本。 我有两个脚本,这样做,并从WMF5.0升级到WMF5.1后,我得到以下错误时,启动DscConfigurations。 VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = ApplyConfiguration,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'. VERBOSE: An LCM method call arrived from computer MYCOMPUTER with user sid S-1-5-21-1064954374-356710528-937385128-34335. VERBOSE: [DESTCOMPUTER]: [] Starting consistency engine. The resources ('[Environment]SetInstantClientPath' and '[Environment]SqlCmdPath') have conflicting values of the following properties: 'Value'. Ensure that their values match. Merging […]

活动目录 – 帐户存在,但无法find它将其删除

我正在尝试添加一个AD托pipe服务帐户,我的第一次尝试如下所示: New-ADServiceAccount -DNSHostName VM-Backup-Service -Name "VM Backup" -samAccountName VM_Backup -Path "OU=AD_Managed_Service_Accounts,DC=company,DC=local" 这个命令基本上是挂起的,我想是因为我把DNSHostName指向了一个不存在的东西,因为我没有做足够的阅读。 然后我尝试纠正它,并使用它的FQDN将它指向主DC。 New-ADServiceAccount -DNSHostName AUDC.company.local -Name "VM Backup" -SamAccountName VM_Backup -Path "OU=AD_Managed_Service_Accounts,DC=company,DC=local" 我现在面临的问题是AD说这个账号已经存在了: New-ADServiceAccount : The specified account already exists 如果我真的能够find所说的帐户,以便在正确地重新添加之前将其删除,那将不是什么大问题。 我已经尝试跟踪它: Get-ADServiceAccount -filter 'samAccountName -like "*VM_Backup*"' Get-ADUser -filter 'samAccountName -like "*VM_Backup*"' 以下内容不会返回任何内容,这意味着域中没有服务帐户? Get-ADServiceAccount -filter * 如果任何人有任何方法来追踪它的build议,将不胜感激。 我唯一的提示是我知道我在上面的命令中指定了samAccountName,并且在它说明帐户已经存在时返回的CN = VM Backup的片段: New-ADServiceAccount : The […]

调整隐式远程会话

概要: 在运行netstat之后,我注意到我的本地设备有几个使用端口5985的远程服务器build立连接,如下所示: PS > netstat Active Connections Proto Local Address Foreign Address State TCP xxxx:3389 10.11.17.12:50603 ESTABLISHED TCP xxxx:5985 device:50581 ESTABLISHED TCP xxxx:5985 172.16.0.54:64858 TIME_WAIT TCP xxxx:5985 172.16.0.54:64859 ESTABLISHED TCP xxxx:5985 172.16.0.54:64860 ESTABLISHED TCP xxxx:5985 172.16.0.54:64861 ESTABLISHED TCP xxxx:5985 172.16.0.54:64862 ESTABLISHED TCP xxxx:5985 172.16.0.54:64863 ESTABLISHED 我的设备将是172.16.0.54。 但是,我只在本地设备上打开了一个单独的PowerShell会话。 题: 一旦用户closures他们的本地机器上的shell是否有办法终止打开的会话? 如果没有,我怎样才能pipe理这些连接? 一旦用户退出本地shell,我宁愿自动closures会话,大多数用户不会使用“Exit-PSSession”。 PS会议结果: PS > Get-PSSession […]

New-NlbCluster访问被拒绝

这是一个问题和答案,因为谷歌search“New-NlbCluster:访问被拒绝”没有带来任何结果,我想分享到社区的同时。 问题: 从2017年4月15日开始,powershell命令行开关New-NlbCluster开始在我们的实验室testing环境中给出一个错误消息:“New-NlbCluster:Access denied”,testing软件的安装和configuration,还包括创build一个新的NLB集群。 该命令也不适用于本地pipe理员帐户。 使用交互式GUI(networking负载平衡)可以很好地创build新的NLB群集。 这里是确切的命令(但有点被掩盖)失败: Import-Module NetworkLoadBalancingClusters try { New-NlbCluster -ErrorAction:Stop -InterfaceName "Xxxxx" -ClusterPrimaryIP "172.17.2.74" -SubnetMask "255.255.255.0" -HostName XX-XX-XX-R1 -ClusterName "xx-xx-xx-rp.xxxxxxxxxx.xx.xxx.com" -OperationMode multicast } catch { echo $_.Exception | format-list -force } ErrorInformation : System.Management.ManagementBaseObject ErrorCode : AccessDenied Message : Access denied Data : {} InnerException : TargetSite : Void ThrowWithExtendedInfo(System.Management.ManagementStatus) StackTrace : […]

以编程方式/从Active Directory远程删除不受信任但“绑定”的Windows

由于一些错误,我有很多机器似乎是从他们这边绑定到Active Directory(AD),而不是在AD的一边。 机器认为他们仍然在公元,但公元不同意。 尝试login时,会导致这个众所周知的“此工作站和主域之间的信任关系失败”错误。 我想远程/以编程方式重置ComputerMachinePassword或以远程/编程方式将它们从AD中取出,然后再次将它们join到AD中。 但是我甚至不能让他们以任何命令离开公元。 我尝试了很多方法,从WMIC的PowerShell到netdom,通常都会得到“权限被拒绝”的错误。 我已经尝试了域pipe理员和本地pipe理员(和组合),远程和机器本身。 但是,我可以通过GUI删除机器。 尽pipe如此,我宁愿不要用大约100台电脑来做这件事;) 问题似乎是,机器本身想要看到ADpipe理权限被删除,我不能得到(因为广告不会(再))。 在这种状态下,有没有办法通过命令行从AD中删除机器(或者不再使用AD)?