我有一些服务器通常有错误1000s。 我想要查找它是否一直是同一个应用程序,或者它是不同的应用程序。 我正在使用这个: Get-EventLog application 1000 -entrytype error -newest 10 | select timegenerated,message | Export-Csv errors.csv 并且输出显示应用程序名称(特别是exe文件)作为多行消息字段的一部分。 我一直无法弄清楚如何从输出中提取应用程序名称。 输出到Get-Member使得它看起来像消息字段是一个数组,但我不知道如何提取该部分的数组在这一点上。 Get-EventLog application 1000 -entrytype error -newest 10 | %{$_.machinename,$_.timegenerated,$_.ReplacementStrings[0]} 这给了我想要的输出,除了它是通过三行生成的,Export-CSV不想正确parsing它。 我怎样才能把他们全部在一行?
我正在尝试将邮箱导出到PST。 昨天之前收到的所有电子邮件都是我试图导出的内容。 $y = ((get-date).addDays(-1)).ToShortDateString() $exportRequest = New-MailboxExportRequest -ContentFilter {(Received -lt $y)} -mailbox userID -FilePath\\SHARED\folder\userID.pst 这有些不对劲。 我最终导出整个邮箱。 当我运行一个: Get-MailboxExportRequest | Get-MailboxExportRequestStatistics | select ContentFilter 它说我的内容filter是: Received -ne $null 我相信这里的语法有些问题,但我似乎无法得到它。
我不能找出参数来更改Notepad ++的默认安装pathC:\Program Files\的当我运行我的PowerShell脚本我要它安装到的驱动器。 我正在尝试进行无提示安装,无法手动更改。 有谁知道我可以添加什么参数来安装程序到E:驱动器? 下面是我的代码和我在PowerShell中尝试的内容。 我一直在使用-ArgumentList参数来弄清楚是否可以将它指向E:驱动器,但目前还没有运气。 我也在Windows Server 2012上运行这个。 function install-Notepadpp() { $install="*PATH*\npp.6.6.2.Installer.exe" Start-Process -FilePath $install -ArgumentList '/InstallDirectoryPath:"E:\"','/S' -Wait -Verb RunAs Write-Host "Notepad++ has been installed." -ForegroundColor Green } ##### This is Windows calling the function to install the script install-Notepadpp
我试图发现是否有我们的服务器上运行碎片整理。 为了保存我自己去每一个加载碎片整理程序,并检查“最后一次运行”列,我想WMI可能有这个信息。 我一直在检查Win32_Volume类,可以看到这可以用来启动磁盘碎片整理和运行分析。 我无法find的是上次完成的任何提及。 我宁愿只是拉一个对象,而不是每次运行一个分析。 有没有办法通过WMI或注册码find这些信息?
我有一个/ 20networking,我想知道所有使用的IP地址和他们的属性,如MAC,名称和说明加上所有使用之间的免费地址,以便我有一个很长的名单,我可以看到地址是否被采取。 幸运的是我有一个Server2012,以便我可以使用Microsoft的CMDLets。 我的意见是要生成所有可能的地址。 最后我想要一个看起来像这样的清单: IP, Mac, Name, Comment 19.0.0.0, 00:00:11:11:11:01, TestUser_1, This is the 1st Testuser . (here are some used and some free) . 19.0.2.45 (this one is free) . 19.0.6.3 (this one is free, too) 19.0.11.201, 11:22:33:44:55:66, TestUser_N, This is just another comment Sampe代码: $x=0 $y=0 $ipstring = "19.0." for ($i=$x;$i -le […]
我有两个PowerShell脚本,我正在build立一个Windows 7的图像。 在映像之前,我运行PRE-IMAGE.ps1,它有这样的一行: $JoinDomainPassword = Read-Host -Prompt "Please enter the password for $joinDomainUser" -AsSecureString $strPass = $joinDomainPassword | ConvertFrom-SecureString 然后将$ strPass安全string保存到registry中,然后运行sysprep。 使用sysprep重新启动后,POST-IMAGE.ps1然后从registry中提取$ strPass,并具有这样一行: $strPass = $strPass | ConvertTo-SecureString $credentials = New-Object System.Management.Automation.PSCredential ($JoinDomainUser, $strPass) 但是,POST-IMAGE.ps1中的这些行会得到您在作为不同Windows用户运行convertto-securestring和convertfrom-securestring时将看到的“Key not valid”错误。 (类似于这个问题 ) – 但这里的catch是我-AM-使用相同的用户来转换和安全的string。 我猜这与sysprep有关 – 但是我无法把头绕在里面。 我很抱歉,如果之前已经询问过这个问题,我已经发现了几个涉及这个问题的问题,但是并没有描述我的问题。
我正在处理一个脚本,可以将它推送到几十台Windows Server 2012 / 2012R2服务器,以启用FSRM文件屏幕,当它们检测到正在写入磁盘的特定文件名时,它将向事件日志中写入警报。 $a = gwmi win32_logicaldisk -filter DriveType=3 | Select -ExpandProperty DeviceID Install-WindowsFeature -Name FS-Resource-Manager -IncludeManagementTools New-FsrmFileGroup -Name "CryptoWall File Monitor" -IncludePattern @("*DECRYPT*") $Notification = New-FsrmAction -Type Event -EventType Warning -Body "Alert text here" -RunlimitInterval 30 foreach ($i in $a){ New-FsrmFileScreen -Path "$i" -IncludeGroup "CryptoWall File Monitor" -Notification $Notification } 现在,脚本本身工作正常,只有一个小问题:运行时,第一个文件屏幕(通常在C :)上具有正确的设置: […]
有些奇怪的东西,我以前没有遇到过。 我们只是做了一个域名迁移,现在当我运行一个Get-ADUser {username} -Properties MemberOf对一个标准用户时,MemberOf属性返回{}。 Get-ADUser lsmith -Properties MemberOf GivenName : Lloyd MemberOf : {} Name : Lloyd Smith ObjectClass : user ObjectGUID : 5a599172-4913-4866-8767-ce8cb7d0887a SamAccountName : lsmith SID : S-1-5-21-2658504567-3195209084-2410544121-3270 Surname : Smith UserPrincipalName : [email protected] 如果我对域pipe理员用户运行同样的命令,MemberOf属性将返回它们所属的组。 但是,如果以pipe理员身份打开PowerShell,则对任何用户运行此命令时都会填充MemberOf属性。 有没有人遇到这个问题? 如果我不需要在通过ASP.Net Web应用程序运行PowerShell脚本时填充该属性,那也不是什么大问题。
我想用PowerShell激活CAPI2(microsoft / windows / capi2)Eventlog。 我怎样才能激活CAPI2 Eventlog? 我没有PowerShell的解决scheme。 但是我确定有PowerShell的解决scheme! 提前谢谢了!
当我尝试使用powershell命令安装Rsat-Hyper-v-tools时:add-windowsfeature rsat-hyper-v-tools -includeAllSubFeature 它失败,错误地说: The source files could not be downloaded. Error: 0x800F0906 另外: CategoryInfo: InvalidOperation: (@(Vhd=; Credent…Name=Localhost):PSObject) .. FullyQualifiedErrorId: DISMAPI_Error__Cbs_Download_Failure 我试图没有成功的谷歌search问题。 可能是与Windows更新或不。 我在这台PC上运行hyper-v,不能安装工具来控制VMS。 有没有其他的方式来启动虚拟机的情况下,我不能使用另一台电脑启动它们? 例如,我正在该VM主机上运行域控制器,如果发生故障,由于没有访问权限(DC down),我无法从另一台PC启动它。 或者,我可以使用PS远程命令与本地PCpipe理员帐户?