Articles of PowerShell

使用“Invoke-WmiMethod”(通过cmd文件)和直接在服务器上安装的msi之间的区别

对服务器安装msi; 活动日志清洁,一切成功; 但是bin direstory中的关键文件仍然很老。 后来尝试直接通过RDP双击进入服务器安装它; 安装成功,bin文件被更新。 – >重新启动没有要求,并没有涉及这两种情况。 – >为什么发生这种情况? 我在哪里可以find更多的日志? – >服务器是Windows 2008 R2

将PowerShell中的2个CSV文件导出到另一个文件中

我已经写了这个脚本,可以发誓我今天早上给了我一个失败,但现在我什么也得不到,不知道为什么。 基本上我需要将$SourceAddress与$OutputAddress进行比较,并导出这些文件与另一个CSV的区别。 任何帮助如何获得输出文件将不胜感激。 或者比“Compare-Object”cmdlet更好的比较方法是非常棒的。 谢谢。 ########################################################### # # Douglas Francis # DNS Audit Script # V 1.2 # Date: 05/06/2014 # # Pulls IP address from a text file. Parses the IP's in the text file for their DNS entry and exports to a CSV file. # For IP address' that do not resolve get […]

寻找一个PowerShell脚本,可以从一组PC和FTP中提取文件

我正在寻找写一个脚本(最好是powershell),将本质上复制一堆PC的文件,并FTP到服务器。 所以环境的结构就是我们有一个需要放在服务器上的多个PC(大约50个左右)的文件。 有时可能会closures其中一台电脑,因此脚本首先需要确保电脑正常运行(可能是ping结果),然后需要进入该电脑上的目录,从中取出一个文件,重命名文件,放入源目录,然后删除文件。 命名约定并不重要,但date/时间戳将是最简单的。 理想情况下,最好先将所有文件移动到源目录以保存FTP带宽,但由于文件名称相同,文件必须在移动过程中重命名。 移动不复制,因为目录需要为空,所以文件可以在第二天重新创build。 所以一旦移动到源目录,现在所有的文件需要FTP'd到服务器进行处理。 所有这一切,我们需要知道列表中的哪些PC没有响应,所以我们可以手动检索文件,所以脚本应该输出一个文件(txt是好的),将显示哪些电脑的离线。 一切都是一个域,脚本将从具有pipe理员权限的服务器运行。 谢谢!

New-ManagedContentSettings – 在Exchange 2010下无法正常工作

我有一个客户将一个业务部门转移到一个新的AD森林,Exchange org等。 我们正在使用Quest工具来迁移用户和邮箱。 但是,我必须build立新的基础设施以配合旧的基础设施。 在旧版本中,我们使用托pipe文件夹邮箱策略来限制(或允许)保留。 他们从Exchange 2007开始,从未升级到保留策略; 好吧。 因此,在旧环境中,当您使用2007服务器定义新的托pipe内容设置时,可以从MessageClass的下拉列表中select“电子邮件”。 这是一个显示名称; 实际的MessageClass值是这样的: MessageClass:IPM.Note; IPM.Note.AS/400移动通知表单v1.0; IPM.Note.Delayed; IPM.Note.Exchange.ActiveSync.Report; IPM.Note.JournalReport.Msg; IPM.Note.JournalReport。 TNEF; IPM.Note.Microsoft.Missed.Voice; IPM.Note.Rules.OofTemplate.Microsoft; IPM.Note.Rules.ReplyTemplate.Microsoft; IPM.Note.Secure.Sign; IPM.NOTE.SMIME; IPM.Note的。 SMIME.MultipartSigned; IPM.Note.StorageQuotaWarning; IPM.Note.StorageQuotaWarning.Warning; IPM.Notification.Meeting.Forward; IPM.Outlook.Recall; IPM.Recall.Report.Success; IPM.Schedule.Meeting *;报告。 IPM.Note.NDR 如果我拿这个,并试图在新的环境中把它换成Ex2010的一个新cmdlet,那么这就是我所得到的 New-ManagedContentSettings -Name "Delete Messages older then 90 days" -FolderName "Entire Mailbox" -RetentionEnabled $True -AgeLimitForRetention 90 -TriggerForRetention WhenDelivered -RetentionAction DeleteAndAllowRecovery -MessageClass "IPM.Note","IPM.Note.AS/400MoveNotificationFormv1.0","IPM.Note.Delayed","IPM.Note.Exchange.ActiveSync.Report","IPM.Note.JournalReport.Msg","IPM.Note.JournalReport.Tnef","IPM.Note.Microsoft.Missed.Voice","IPM.Note.Rules.OofTemplate.Microsoft","IPM.Note.Rules.ReplyTemplate.Microsoft","IPM.Note.Secure.Sign","IPM.Note.SMIME","IPM.Note.SMIME.MultipartSigned","IPM.Note.StorageQuotaWarning","IPM.Note.StorageQuotaWarning.Warning","IPM.Notification.Meeting.Forward","IPM.Outlook.Recall","IPM.Recall.Report.Success","IPM.Schedule.Meeting.*","REPORT.IPM.Note.NDR" […]

:从Powershell Register-ClusteredScheduledTask

我想在非群集服务器上执行我的任务,并将它们作为群集任务导入到已构build和testing的新群集中。 以下是我所尝试的: cls $xmlFilename="i:\Scripts\ImportScheduledTasks\CleaupMessageLog.xml" $xmlContents = get-content $xmlFilename Register-ClusteredScheduledTask -TaskName "TestXMLTask" -TaskType AnyNode -Xml $xmlContents XML导入到Windows任务计划程序中,但不是“集群”任务。 这是我运行上面的代码时得到的错误: Register-ClusteredScheduledTask : Cannot process argument transformation on parameter 'Xml'. Cannot convert value to type System.String. At C:\Users\nwalters\Documents\TestWebSampleCode4FromXML.ps1:4 char:80 + Register-ClusteredScheduledTask -TaskName "TestXMLTask" -TaskType AnyNode -Xml $ … + ~ + CategoryInfo : InvalidData: (:) [Register-ClusteredScheduledTask], ParameterBindingArgumen tTransformationException + […]

从PowerShell错误添加一个新的Exchange 2013邮箱

我试图通过Powershell添加一个新的邮箱,我得到以下错误: #New-ADUser -Name AreallyTest -SamAccountName AreallyTest -AccountPassword (ConvertTo-SecureString Password1234 -AsPlainText -Force) -Enabled:$true -Company land -HomeDrive Z: -ChangePasswordAtLogon:$true -Path 'cn=DC01,DC=internal,DC=land,DC=edu'| Enable-Mailbox -Identity Novell\AreallyTest -Alias Novell\AreallyTest New-ADUser : Directory object not found At line:1 char:1 + New-ADUser -Name AreallyTest -SamAccountName AreallyTest -AccountPassword(Conve …+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ + CategoryInfo : ObjectNotFound: (CN=AreallyTest,…=land,DC=edu:String) [New-ADUser], ADIdentityNotFoundException + FullyQualifiedErrorId : ActiveDirectoryCmdlet:Microsoft.ActiveDirectory.Management.ADIdentityNotFoundException,Microsoft.ActiveDirectory.Management.Commands.NewADUser 如果我试图通过它自己添加邮箱,我得到这个错误(它正在寻找。内部) […]

POWERSHELL:术语“新接受的域”不被识别为cmdlet的名称

我正试图build立一个多租户交换2013环境。 目前我们有2013年的生产环境,有几家公司正在使用它。 然而,缺点是每个公司都可以看到由于单个GAL而产生的其他地址。 我已阅读,为了缓解这一点,我必须按照这里的说明build立多租户> https://www.geekandi.com/2013/08/02/exchange-2013-multi-tenancy-step-by-step/ 我卡在我创build一个新的AcceptedDomain的部分(见下面的错误) PS C:> New-AcceptedDomain -Name“New Tenant 1”-DomainName test.exchange -DomainType:Authoritative New-AcceptedDomain:术语“New-AcceptedDomain”不被识别为cmdlet的名称,>函数,脚本文件,或可操作的程序。 检查名称的拼写,或者如果包含path,请validationpath>是否正确,然后重试。 在行:1个字符:1 +新接受的域名-Name“新的租户1” – 域名test.exchange -DomainType:金… + ~~~~~~~~~~~~~~~~~~ + CategoryInfo:ObjectNotFound:(New-AcceptedDomain:String)[],CommandNotFoundException + FullyQualifiedErrorId:CommandNotFoundException 我试图在MB Svr,CA Svr和AD svr上运行这个shell命令! 任何帮助将不胜感激

是否可以将Azure VM映像从一个订阅迁移到另一个订阅?

我最近在一个存储帐户中捕获了一个azure色的vm映像,并计划将此映像迁移到另一个不同订阅的另一个存储帐户。 我使用PowerShell脚本来运行这个任务,但我遇到了这个问题:没有find存储帐户。 还有一个问题是,PowerShell必须与特定的Azure帐户相关,否则无法运行脚本。 那么故事就是如何使用PowerShell同时控制不同的订阅,并执行迁移任务? 谢谢。 顺便说一句,PowerShell脚本如下所示: 更改这些以匹配来源帐户 $ sourceStorageAccountName =“”$ sourceContainerName =“”$ sourceStorageKey =“”#需要从不同的订阅中移动数据 目的地帐户信息 $ destStorageAccountName =读取主机“input目标存储帐户名称”$ destStorageAccountKey = Get-AzureStorageKey $ destStorageAccountName | %{$ _主要} $ destContainerName =读取主机“input目的地容器名称” $ sourceContext = New-AzureStorageContext -StorageAccountName $ sourceStorageAccountName -StorageAccountKey $ sourceStorageKey -Protocol Http $ destContext = New-AzureStorageContext -StorageAccountName $ destStorageAccountName -StorageAccountKey $ destStorageAccountKey $ uri = $ […]

PowerShell格式化一个已经是string的值

我有一些我想要以特定方式格式化的值。 要非常清楚,它的IP地址八位字节,我希望它在“xxx”格式。 例如,如果我有一个八位字节值为“20”我想显示为“020”而不是“20”。 我最终会有一个数组填充IP,我想正确格式化所有这些。 这是我知道的一个例子,我已经想出了一个get-member这个整数。 $Test = 1 $Test.ToString("000") 001 这是行不通的。 我已经通过Get-Member计算出该值已经是string了。 $Test = "1" $test.ToString("000") Cannot find an overload for "tostring" and the argument count: "1". At line:1 char:2 + $test.tostring("000") + ~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodException + FullyQualifiedErrorId : MethodCountCouldNotFindBest 任何想法如何我可以得到已经是一个string格式化的值,我可以与值是一个整数? 长期以来,我希望示例$testing将实际上包含一个完整的IP地址。 例如10.10.10.10我想成为010.010.010.010 对于那些有兴趣的人 通过使用@GregL的例子,我能够整合一个完整的IP格式的前导零的工作示例,以供参考。 $Test = "10.10.10.10" $test2 = […]

通讯组所有者pipe理Exchange PowerShell

在Exchange 2010(版本14.3 Build 123.4)环境中,如何将新用户添加到“ManagedBy”属性并通过PowerShell同时删除另一个用户? (我将这样做使用foreach多个列表) 在此TechNet博客文章中, http://blogs.technet.com/b/dstrome/archive/2011/05/29/multivalued-properties-in-exchange-2010.aspx数组语法(我已尝试添加之前删除,相同的结果): Set-DistributionGroup Sales -ManagedBy @{Remove="David"; Add="Gerald"} 导致消息: All groups must have at least one owner who manages membership, message approval, and other settings for the group. 什么是从Exchange 2010通讯组添加和删除pipe理器的正确方法?