我只是一名初级程序员,刚开始使用编程,因为我的工作要求我创建一些方便的PowerShell脚本我想知道如果你能帮助我一个特别的一个。创建powershell脚本以在桌面上启用显示+使用主机名重命名
我们有很多有很多服务器的客户。当他们新安装时,我会检查他们,之后我们会定期进行维护。由于每个客户都有多个角色不同的服务器,因此我想在桌面上安装“计算机”图标。 我能做到这一点通过点击开始 - >右击计算机 - >启用“显示在桌面上” Furtheron我想有更名为主机名该计算机图标(因为主机名告诉我,在域中它的作用)
现在我的目标是创建一个PowerShell脚本,为域中的所有服务器创建带有主机名的计算机图标。
我试着我的方式搜索到通常的搜索引擎以及与此想出了:
1)用注册表编辑器[HKEY_CLASSES_ROOT\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}
重命名LocalizedString定位到LocalizedString.Old 2)现在切换到的Regedit32创建一个新的价值键入Expand_SZ的名称它LocalizedString在XP和Windows 2000与SP3取代LocalizedString与%Username% at %Computername%
这是不适合,因为我们使用W2K8R2SP1服务器。 之后,我结束了与此脚本:
$ComputerName = "Localhost"
$Hive = "CurrentUser"
$Key = "Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel"
$MyComputer = "{20D04FE0-3AEA-1069-A2D8-08002B30309D}"
$UserFiles = "{59031a47-3f72-44a7-89c5-5595fe6b30ee}"
$Kind = [Microsoft.Win32.RegistryValueKind]
$RegHive = [Microsoft.Win32.RegistryHive]$hive
$RegKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($RegHive,$ComputerName)
$MyComputerValue = ($RegKey.OpenSubKey($Key)).GetValue($MyComputer)
$UserFilesValue = ($RegKey.OpenSubKey($Key)).GetValue($UserFiles)
if ($MyComputerValue -eq $null -or $MyComputerValue -eq 0)
{
$Computer = $regKey.OpenSubKey($RootKey,$true)
$Computer.SetValue($MyComputer, 1,$Kind::DWord)
}
if ($UserFilesValue -eq $null -or $UserFilesValue -eq 0)
{
$User = $regKey.OpenSubKey($RootKey,$true)
$User.SetValue($UserFiles, 1,$Kind::DWord)
}
这似乎并没有在所有做任何事情。
我知道这个注册表键用于在台式电脑:
“{20D04FE0-3AEA-1069-A2D8-08002B30309D}”=dword:00000000
续搜索... 所以我发现这一点:
To show the ‘My Computer’ icon on the desk"text-decoration:underline;">
[HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel]
Name = {20D04FE0-3AEA-1069-A2D8-08002B30309D}
Type =REG_DWORD
Value = 0
To change the ‘My Computer’ icon to computer or user name:
[HKCR\CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}]
Name = LocalizedString
Type = REG_EXPAND_SZ
Data value = %computername% or any combination you like – eg %username% %computername%
但是第二部分一直给我一个错误,即使我可以得到它的工作,我想运行脚本onces和域中的所有服务器应该有此更新。
感谢您的帮助。
最好的问候,
尼克