如何使用Powershell重命名AD域中的计算机?
我已经find了一种方法来加载交换2010 PowerShell到在Windows XP工作站上运行的PowerShell,但是有一些命令需要运行。 我想知道如何将它们加载到configuration文件中。 这些是我可以执行Get-Mailbox之类的任何交换之前需要运行的命令。 COMMAND 1 $ session = New-PSSession -Configurationname Microsoft.Exchange -ConnectionUri http:// servername / powershell -Credential $ user (它提示你input用户名和p / word然后下一个命令) COMMAND 2导入PSSession $会话 然后,我可以运行Exchange 2010命令,例如Get-Mailbox。 无论如何,我可以加载这些,所以当我点击PowerShell的快捷方式,他们预先导入交换命令的导入。 谢谢
我find了指针 ocsetup MicrosoftWindowsPowerShell 要么 start ocsetup MicrosoftWindowsPowerShell 但他们没有效果。
我知道有这个sc.exe可以添加和设置Windows服务依赖关系,但我想知道是否可以使用Powershell完成同样的事情。
我试图从Windows安全日志中分析logging,并且有些难以从某些login/注销事件中获取特定值。 让我们来看一个具体的例子 – 这里是一个日志条目的XML。 <Event xmlns='http://schemas.microsoft.com/win/2004/08/events/event'> <System> <Provider Name='Microsoft-Windows-Security-Auditing' Guid='{54849625-5478-4994-a5ba-3e3b0328c30d}'/> <EventID>4634</EventID> <Version>0</Version> <Level>0</Level> <Task>12545</Task> <Opcode>0</Opcode> <Keywords>0x8020000000000000</Keywords> <TimeCreated SystemTime='2011-08-16T17:15:38.702857400Z'/> <EventRecordID>107947</EventRecordID> <Correlation/> <Execution ProcessID='680' ThreadID='972'/> <Channel>Security</Channel> <Computer>SRV1.DOMAIN.LOCAL</Computer><Security/> </System> <EventData> <Data Name='TargetUserSid'>S-1-5-21-963414502-3093649508-813756320-3274</Data> <Data Name='TargetUserName'>billgates</Data> <Data Name='TargetDomainName'>MYDOMAIN</Data> <Data Name='TargetLogonId'>0x1c01acc</Data> <Data Name='LogonType'>10</Data> </EventData> </Event> 我将如何去提取存储在Data节点中的Name属性等于'TargetLogonId' ?
我有一个函数,我知道会抛出一个错误。 这个错误是预期的,但是当它被抛出时,我想结束这个函数。 我在脚本中有一个陷阱部分,我已经使用了Return和Break命令,但是他们没有做我想要的。 我在Begin {}和Process {}部分都有陷阱声明。 我正在使用Get-WmiObject命令,并将-ErrorAction设置为stop 。 代码示例及其响应如下。 第一个例子w / return: Function Test { Param {"Some Parameters"} Begin {"Some beginning stuff"} process { Trap { Add-Content $($SomeFile) $($ComputerName + "is Not There") return } #End Trap Get-WmiObject Win32_NTLogEvent ` -ComputerName $ComputerName ` -Credential $Cred – ` -ErrorAction Stop }#End Process End {"Some ending things"} […]
我想使用命令行工具列出(主)区域的configuration辅助服务器(如果有的话)。 Dnscmd接近: dnscmd server /ZoneResetSecondaries:[list of secondaries] 但是,我不想打破任何目前的设置,我只想审查它们。 PowerShell(甚至在Server 2012上)似乎没有帮助。 谢谢。
我写了这个cmdlet: Search-ADAccount -filter {(enabled -eq $true)} -Users Only -SearchBase "ou=FirstOU,dc=domain,dc=com" -AccountInactive -TimeSpan 30 但是它输出一个错误: Search-ADAccount : A parameter cannot be found that matches parameter name 'fil ter'. At line:1 char:25 + Search-ADAccount -filter <<<< {(enabled -eq $true)} -UsersOnly -SearchBase " ou=FirstOU,dc=domain,dc=com" -AccountInactive -TimeSpan 30 + CategoryInfo : InvalidArgument: (:) [Search-ADAccount], Paramet erBindingException + FullyQualifiedErrorId : […]
我有一个PowerShell脚本检查证书存储过期的证书。 它将在CLI中显示这些结果。 我想修改这个脚本,通过电子邮件的forms发送输出结果。 我知道如何通过PowerShell使用send-mailmessage CmdLet发送电子邮件,但我不确定如何获取脚本的结果并通过电子邮件发送。 这是脚本: param([int]$InNumberOfDays=180,[switch]$ExcludeAutoEnroll) function WriteCertInfo($cert) { #just a lot of code to get the fields into an object $certObj = "" | Select RequesterName,RequestType,ExpirationDate,CommonName,EnrollmentFlags $RequesterName=$cert -match "Requester Name:.*Request Type:" $startLength="Requester Name:".Length $lineLength=$matches[0].Length -("Request Type:".Length + $startLength) $OutRequesterName=$matches[0].SubString($startLength,$lineLength) $certObj.RequesterName=$OutRequesterName $RequestType=$cert -match "Request Type:.*Certificate Expiration Date:" $startLength="Request Type:".Length $lineLength=$matches[0].Length – ("Certificate Expiration Date:".Length […]
根据本指南,我尝试创build一个用于签署PowerShell脚本的证书: CD C:\OpenSSL-Win32\bin REM Create the key for the Certificate Authority. 2048 is the bit encryptiong, you can set it whatever you want openssl genrsa -out C:\Test\ca.key 2048 openssl req -config C:\OpenSSL-Win32\bin\openssl.cfg -new -x509 -days 1826 -key C:\Test\ca.key -out C:\Test\ca.crt REM Now I'm creating the private key that will be for the actual code signing […]