我想使用PowerShell重新启动远程机器上的服务。 该服务具有显示名称和实例名称。 我可以使用Restart-Service cmdlet来执行此操作吗? 我没有看到一个instancename参数,我似乎无法使“displayname $ instancename”的语法工作。 这个语法不起作用: Invoke-Command -Session $session -ScriptBlock {Restart-Service -displayname 'DisplayName$InstanceName' -PassThru} 我首先想到的问题是$字符,但是我发现这个语法是可行的: Get-Service 'displayname$instancename'
如果我尝试运行: New-ActiveSyncMailboxPolicy Test 直接在Powershell中,它会询问我是否确定,如果是的话,它会做它应该做的。 但是,如果我从我的示例代码在C#中尝试相同,那么我得到一个错误,说“当前主机不执行它”。 其他像Set-CASMailbox或Get-ActiveSyncMailboxPolicy这样的命令在powershell和我的应用程序中都可以正常工作。 Exchange Server / Windows Server 2008 R2和域都是全新build立的(testing环境)。 有没有办法让这成为可能?
我inheritance了一些代码,其中一个脚本引用另一个像这样: #Script1.ps1 param($arg1) # do some stuff # call script2 with argument from script1 .\script2.ps1 $arg1 #script2.ps1 param($arg1) # do some stuff unique to this script 这在本地工作正常,但是当这两个脚本部署到远程服务器,并通过invoke-command调用script1时,远程PS实例抱怨找不到script2: invoke-command $remoteServer { param($arg1, $remoteScript) powershell $remoteScript $arg1 } -argumentList $arg1, $remoteScript # output from script1 # more output from script 1 # here comes the error when […]
我正在与iis arr powershell …在我的iis我有一个networking农场,在那里我有两个服务器“server1”和“server2”…… 我的任务是 使server1不能正常使用 重新启动server1 iis 使可用的server1 … 使server2不能正常使用 重新启动server2 iis 提供服务器2 …… 但问题是在使server1“不能正常使用”之后,重新启动server1之后,iis的“可用性”和“健康状态”(在监视和pipe理中)将进入“未知”状态,现在iam无法使server1可用,喜欢 例外是: Exception calling "Execute" with "0" argument(s): "The request is not supported. (Exception from HRESULT: 0x80070032)" At line:19 char:28 + $methodInstance.Execute <<<< () + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException 任何人都可以知道如何使用PowerShell(如果处于未知状态)解决scheme
我们使用一个基于networking的软件,用户可以login到该软件,以pipe理访问由AD组控制的共享。 用户可以pipe理的组列表是他们具有“写入成员”安全性的组。 这允许用户维护文件共享而不需要知道AD。 我正在尝试使用quest.activeroles.admanagement编写Powershell脚本,该脚本将返回指定用户具有“写入成员”安全性的整齐列表,以清除离职用户的权限。 我需要search的组存储在一个OU中,尽pipe有超过1000个。 我到目前为止已经想出了: add-pssnapin quest.activeroles.admanagement Get-QADObject -ShowProgress -SearchRoot 'domain.server.com/path/to/OU' -SearchScope 'OneLevel' -Type Group -SizeLimit 2500 | Get-QADPermission -Rights 'WriteProperty' -Property 'member' -Account "user" -WarningAction SilentlyContinue 这工作正常(但效率不高),但主机输出相当混乱: Permissions for: full.domain.path/OU/path/group1 Ctrl Account Rights Source AppliesTo —- ——- —— —— ——— Domain\user Write member Not inherited This object and all child objects Permissions for: […]
有没有优雅的方式来删除使用自动化,Powershell或Exchange电子邮件地址策略的用户的电子邮件地址? 有问题的平台是Exchange 2007。 我想修改离开的用户的电子邮件地址,使他们的地址将变成[email protected]或类似的东西,删除其旧的[email protected]的地址。 本文 (Serverfault; Exchange 2010)build议地址只使用电子邮件地址策略进行添加,所以我假设我将不得不使用其他方法。 build议? 优雅的build议?
我想对我的$ profile文件进行很多更改。 保存更改后,我想使用“sop”别名来源文件。 以下是我希望能够实现的目标: set-alias sop Source-Profile function Source-Profile { . $profile } 这个函数不会抛出任何错误,所以它似乎工作。 但是,当我做我的$configuration文件的更改,这个function似乎没有任何东西。 我还是要打字. $profile 从PS提示重新评估该文件. $profile文件。 没关系,但这是一个小小的痛苦。 我宁愿使用别名来源文件。 我在这里错过了什么?
我有很多不同名字的文件每天。 我怎样才能按他们的名字过滤他们的date? 例如: app_20130505.log app_20130506.log app_20130507.log app_20130508.log app_20130509.log 和我的代码片段: $RetainedDays = 7 $FileNameRegex = "\w+_(\d+)\.\w+" $ArchiveBoundary = $(Get-Date -Format yyyyMMdd) – $RetainedDays $ProcessFiles = Get-ChildItem -Path $RootPath -Recurse | Where-Object { $_.Name -match $FileNameRegex } 我有正则expression式筛选它: \w+_(\d+)\.\w+ ,这使我在$匹配variables中的date,但我怎么能结合他们,并取回文件列表,与这些文件7天以上?
我试图build立一个脚本来运行我的虚拟机的备份只使用WBADMIN,我已经有了能够使用新的-HyperV交换机备份所有的虚拟机,但是我也想备份HyperV主机组件。 有没有人有这样做的经验或可以指向我的一些文件(微软忽略这个新的-HyperV开关) 这是我的PowerShell脚本如果你感兴趣的话: #Constant Variables $Day = Get-Date $Day = $Day.DayOfWeek $Date = Get-Date -format hhmmddMMyyyy $Server = hostname #Set Paths $BackupPath = "\\backup\Backups\" + $Server + "\" +$Day $LogPath = "\\backup\Backups\" + $Server + "\Logs\" + $Date +".txt" # SELECT Virtual Machines $VMList = $null $VMs = Get-VM | Select-Object VMId for ($i = […]
我已经加载了几十个registryconfigurationHKLM:\temp_$username\ 。 现在当我尝试运行ls HKLM:\temp_* | %{reg unload $_} ls HKLM:\temp_* | %{reg unload $_}我得到ERROR: Access is denied. 我运行提升priveleges的PowerShell,并尝试重新启动PowerShell ISE清除variables。 我仍然收到错误。 我可以使用GUI卸载蜂箱,我可以运行单个蜂箱的命令( reg unload HKLM\temp_jimbob ),所以我有点困惑,为什么命令不会运行多个蜂箱。 什么导致访问被拒绝的错误,我该如何解决?