Articles of PowerShell

如何在PowerShell中导出registryHIVE(NTUSER.DAT)

为了解决由三星打印驱动程序引起的registry膨胀问题,我需要find一种方法来导出用户的漫游configuration文件NTUSER.DATregistryconfiguration单元,同时在PowerShell中。 加载和导出一个NTUSER.DAT Registry Hive在REGEDIT中工作,但是到目前为止我还没有find在PowerShell中这样做的方法。 我正在使用的PowerShell脚本能够加载远程registryconfiguration单元,删除密钥并卸载。 这不提供从registryconfiguration单元文件中删除空闲空间的方法。 当在REGEDIT中手动执行此操作时,我已经能够使用超过150,000KB的臃肿NTUSER.DAT文件,然后将它们作为新的NTUSER_Clean.DATregistryconfiguration单元一直下降到780KB(对于设置相对较less的用户) 。 PowerShell示例代码: Write-Host "Attempting to load the User Roaming Profile Registry HIVE (NTUSER.DAT)." #Write-Host $strRemoteLocation reg load "HKU\$strKeyName" $strRemoteLocation Write-Host $strLine Write-Host "Attempting to clean the Registry HIVE of Samsung SSPrint Keys." Clean_Key $strKeyName "spd__" Clean_Key $strKeyName "spe__" Clean_Key $strKeyName "ssp6m" Write-Host $strLine # Export Registry HIVE to […]

什么是删除旧的configuration文件造成的附带损害?

#Get user names that have logged onto workstation $Users = gwmi win32_networkloginprofile | where {$_.name -match "EXP\\"} | where {$_.name -notmatch "srvtasksched"} $Users | foreach{ $Name = $_.Name $LastLogon = $_.LastLogon $LogonTime = [System.datetime]::ParseExact($LastLogon.Substring(0, $LastLogon.IndexOf(".")), "yyyyMMddHHmmss", [System.Globalization.DateTimeFormatInfo]::InvariantInfo) if($(Get-Date).Subtract($LogonTime).TotalDays -ge 14) { #User hasn't logged into workstation in over 2 weeks #Get profile path $UserSID = […]

错误0x8007007e尝试在Windows 7中使用Powershell安装WinPE 5 wim

使用ADK for Windows 8.1以及随附的DISM cmdlet。 我已经安装了WMF 4.0。 我的机器是Windows 7 x64 SP1,我正在尝试使用wim来装载 PS C:\Users\BigHomie> Mount-WindowsImage -ImagePath 'C:\Program Files (x86)\Windows Kits\8.1\Assessment and Deployment Kit\Windows Preinstallation Environment\x86\ en-us\winpe.wim' -Path C:\WinPE_x86 -index 1 并收到以下错误: Mount-WindowsImage : DismInitialize failed. Error code = 0x8007007e At line:1 char:1 + Mount-WindowsImage -ImagePath 'C:\Program Files (x86)\Windows Kits\8.1\Assessmen … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ + CategoryInfo : […]

PowerShell中的-RetentionDays和-MaximumSize参数如何工作在Limit-EventLog中?

我想使用Powershell来增加Windows应用程序日志的大小,并打算使用Limit-EventLog 。 我必须保留至less7天的日志,并有足够的磁盘空间(至less达到4GB的限制)。 我的问题是,如果我运行这样的命令: Limit-EventLog -LogName "Application" -MaximumSize 4092MB -RetentionDays 7 -OverflowAction "OverwriteOlder" 如果事件日志中有超过7天的事件,并且有很多可用空间,Windows保留最早的logging,还是开始覆盖超过7天的事件? 如果我已经达到了7天的保留期限,我不想不必要地增加日志。 我不确定这两个参数是如何协同工作的,而且文档不够明确。

使用diskpart格式化磁盘,如果没有格式化

我正在尝试编写脚本来在Windows Server 2008 R2中创build和格式化分区。 现在,当disk 1被选中时,我需要格式化它, 只要它没有格式化 。 这是我现在所拥有的: 运行: diskpart /s script.txt script.txt内容 select disk 1 clean create partition primary format fs=ntfs unit=65536 quick active assign letter=D 任何帮助?

如何从命令行或PowerShell中获取为Exchange安装的RU,SP和其他更新的列表?

有没有办法从命令行,PowerShell或Exchange命令行pipe理程序获取为MS Exchange服务器安装的更新,汇总和服务包列表? 我已经尝试过Get-Hotfix , Get-WmiObject和Systeminfo但是上面的所有内容似乎都只返回了为系统(Windows)而不是为Exchange安装的更新列表。 编辑: Get-ExchangeServer不满足我的需求,因为Exchange 2010 SP3它似乎总是报告生成版本123.4尽pipe所有新的汇总安装和实际构build号码是224.2。

从Windows Server 2003 Powershell 2.0发送邮件通知到Office 365

我的脚本是为了吸收不正确完成的计划任务中的错误,并通过Office365将它们发送到我的电子邮件地址: $reportHTML = Get-Content C:\windows\tasks\SchedLgU.Txt | Select-String -Pattern "an exit code of \(1\)" -context 2 $reportHTML = Out-String -InputObject $reportHTML #TODO Add an if statement $emailUsername = "[email protected]" #TODO: Change this to a file…. #$emailPassword = cat "C:\ps\emailCred.txt" | convertto-securestring $emailPassword = ConvertTo-SecureString "somepassword" -AsPlainText -Force $emailCred = new-object -typename System.Management.Automation.PSCredential($emailUsername, $emailPassword) Send-MailMessage -To "[email protected]" […]

PowerCLI自动设置-cddrive错误

当试图在开启的guest虚拟机实例上更改ISO时,set-cddrive返回错误,但是完成该命令。 几个不同的命令产生相同的结果: $theVM | Get-CDDrive | Set-CDDrive -NoMedia -Confirm:$false $theVM | Get-CDDrive | Set-CDDrive -Connected $true -ISOPath $iso -Confirm:$false 两者都产生:Set-CDDrive操作由于对象的当前状态而无效 那可能是什么状态? set-cddrive依赖于CusomizeVM_Task还是ReconfigVM_Task? 踢球者在这里是操作似乎成功,即使它返回一个错误。 编辑: 错误现在已经改变为“ide0:0已经存在”,脚本没有任何改变。 发现这个KB,表明它可能是一个错误: http : //kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2092716

Windows删除DNS服务器

我有一个DNS服务器是行为不端。 我的一些Windows机器只有2个DNS服务器 server01 192.0.2.1 server02 192.0.2.2 我的一些Windows机器有3个DNS服务器 server01 192.0.2.1 server02 192.0.2.2 server03 192.0.2.3 我怎样才能从我的dns设置使用powershell删除server03(192.0.2.3)? PS C:\Windows\system32> Get-DnsClientServerAddress InterfaceAlias Interface Address ServerAddresses Index Family ————– ——— ——- ————— Ethernet 2 12 IPv4 {192.0.2.1, 192.0.2.2, 192.0.2.3} Ethernet 2 12 IPv6 {} Loopback Pseudo-Interface 1 1 IPv4 {} 我有非常小的窗口经验。 在linux上,我会编辑resolv.conf 更新这些是Windows 2012 R2服务器

使用PowerShell将一个网站从一台服务器移到另一台服务器

我一直在阅读有关MS部署和编写一个小脚本导出/导入一个网站从一台服务器到另一台服务器(IIS8到IIS8)。 但我遇到了大小问题和其他一些错误,整个过程似乎是一个网站的矫枉过正。 所以我想知道是否有通过PowerShell更简单的方法呢? 使用PowerShell,有没有办法导出和导入一个网站? 谷歌search显示很多,但我认为必须有一个方法。 谢谢