有没有人知道如何通过数以千计的子目录search只包含1个文件,不超过1个文件的所有目录? 任何build议使用什么工具或简单的代码片段?
我已经为Powershell模块创build了一个中央存储库,但是我特别在加载它时遇到了麻烦。 NTFSSecurity模块无法导入以下消息。 PS Z:\> Import-Module NTFSSecurity Add-Type : Could not load file or assembly 'file://\\fs\PowerShellModules\NTFSSecurity\Security2.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) At \\fs\PowerShellModules\NTFSSecurity\NTFSSecurity.Init.ps1:141 char:1 + Add-Type -Path $PSScriptRoot\Security2.dll + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Add-Type], FileLoadException + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.AddTypeCommand Add-Type : Could not load file or […]
我有一个在有很多驱动器映射设置的域中的组策略。 如果可能的话,我想用PowerShell为这个gpo中的很多服务器改变path。 我知道我可以通过GPMC做到这一点,但宁愿做一些程序devise。 我已经从microsoft(get-gpo和friends)看过了grouppolicy的powershell模块,但是我似乎只能改变policys的registry信息和权限,而不是drivemapping的实际path。 有任何想法吗? 谢谢!
我们正在切换到WDS进行部署,所以我正在编写一个PowerShell脚本来ping一台计算机,如果它响应,获取它的MAC地址,并在Active Directory中设置netbootGUID字段。 它运行和工作…一段时间,然后返回: Get-ADComputer:服务器返回了以下错误:枚举上下文无效。 \ Path \ To \ Scripts \ setNetbootGUIDremoteComputers.ps1:3 char:15 get-adcomputer <<<< -Filter * -searchbase“OU = Somehwere,DC = My,DC = AD,DC = TLD”-ResultSetSize $ null | foreach-object { CategoryInfo:NotSpecified:(:) [Get-ADComputer],ADException FullyQualifiedErrorId:服务器返回了以下错误:枚举上下文无效。,Microsoft.ActiveDirectory.Management.Commands.GetADComputer 这是脚本: import-module ActiveDirectory get-adcomputer -Filter * -searchbase "OU=Somewhere,DC=MY,DC=AD,DC=TLD" -ResultSetSize $null | foreach-object { $strComputer = $_.Name $ping = new-object System.Net.NetworkInformation.Ping $Reply […]
我希望能够检查CCM更新计划,如Configuration Manager更新选项卡中所示。 我一直在寻找谷歌,我一直没能find一致的答案。 我试图使用UDA.CCMUpdatesDeployment创build一个COM对象。 这使我能够使用SetUserDefinedSchedule方法成功设置重复计划。 如果我尝试使用GetUserDefinedSchedule,我只能得到variables的原始值。 PS> $UD = New-Object -com "UDA.CCMUpdatesDeployment" PS> $A= 101 PS> $B= 102 PS> $UD.GetUserDefinedSchedule([ref]$A, [ref]$B) PS> $A 101 PS> $B 102 PS> $UD.GetUserDefinedSchedule MemberType : Method OverloadDefinitions : {void GetUserDefinedSchedule (Variant, Variant)} TypeNameOfValue : System.Management.Automation.PSMethod Value : void GetUserDefinedSchedule (Variant, Variant) Name : GetUserDefinedSchedule IsInstance : True 我实际上希望能够远程执行文本文件中的服务器列表,但现在任何方式都可以。
我们正在使用ARR作为反向代理,我想由于各种原因使服务器不可用。 这怎么可以使用Powershell来完成? 编辑1: 我发现这个使用JScript的http://blogs.iis.net/anilr/archive/2009/11/09/using-arr-config-extensibility-to-gracefully-stop-server.aspx教程。 但是我不能把它翻译成PowerShell。 编辑2: 使用Webpipe理模块中的Set-WebConfigurationProperty,我可以更改服务器的设置。 我在%windir%\system32\inetsrv\config\schema\arr_schema.xmlfind了SetState,但我不知道如何调用该方法。
我正在使用Powershell处理Office 365 Exchange实例,并且遇到了一个我知道我已经成功运行的命令。 我已经把这个命令分解成它的子部分,并自行运行它们,但似乎无法使这个ForEach循环工作。 我可能在这里错过了什么? PS C:\Users\bsigrist> ForEach ($Mailbox in (Get-Mailbox -RecipientTypeDetails UserMailbox)) { $cal = $Mailbox.alias+":\Calendar" Set-MailboxFolderPermission -Identity $cal -User Default -AccessRights LimitedDetails } At line:1 char:108 + … cal = $Mailbox.alias+":\Calendar" Set-MailboxFolderPermission -Identi … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unexpected token 'Set-MailboxFolderPermission' in expression or statement. + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordExcep tion + FullyQualifiedErrorId […]
我使用此命令安装了一个脱机的根CA,没有问题: Install-ADcsCertificationAuthority ` -OverwriteExistingKey ` <#In the case of a re-installation#> ` -AllowAdministratorInteraction ` -CACommonName ` "LAB Corporate Root CA" ` -CADistinguishedNameSuffix ` 'O=LAB Inc.,C=US' ` -CAType ` StandaloneRootCA ` -CryptoProviderName ` "RSA#Microsoft Software Key Storage Provider" ` -HashAlgorithmName ` SHA256 ` -KeyLength ` 2048 ` -ValidityPeriod ` Years ` -ValidityPeriodUnits ` 20 ` -DatabaseDirectory […]
我正在尝试将远程桌面部署的设置编写到Azure中。 我使用Powershell远程连接到虚拟机上的WinRM端点并执行远程Powershell。 在大多数情况下这工作得很好,并允许我configuration服务器,安装应用程序等 但是,当我使用New-RDSessionDeployment命令实际安装远程桌面组件时,遇到了问题。 此部署中有两台服务器: RD-GTW,它将承载远程桌面网关和Web访问服务 RD-RDS,它将主持一个会话主机和连接代理 我正在如下运行RD-GTW服务器的New-RDSessionDeployment命令(使用invoke-command) New-RDSessionDeployment -ConnectionBroker RD-RDS.domain.local -WebAccessServer RD-GTW.domain.local -SessionHost RD-RDS.domain.local 然后返回一个错误: Validation failed for the "RD Connection Broker" parameter. RD-RDS1.domain.local Unable to connect to the server by using Windows PowerShell remoting. Verify that you can connect to the server. + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,New-RDSessionDeployment […]
所以我有一个数组 ,我需要通过逐行search和接口分割。 我的代码一行一行地循环遍历这个文件。 我想通过“!”分割接口 字符,并将string添加到数组中的元素,以便我可以进一步parsing。 以下是该文件的内容。 ! interface Loopback0 description MANAGEMENT ip address 172.xxx.xxx.x ! interface FastEthernet0/0 description m<1> A<LAN on chr-city> no ip address ip flow ingress duplex auto speed auto ! interface FastEthernet0/0.50 description Management encapsulation dot1Q 50 native ip address 172.xxx.xxx.x ! interface FastEthernet0/0.51 description Transit encapsulation dot1Q 51 ip address 172.xxx.xxx.x […]