zoukankan
html css js c++ java
PowerShell编写小记 之 MiNiTools
运行前 要在PowerShell里运行set-executionpolicy remotesigned
set-executionpolicy remotesigned Start-Sleep -s 2 #激活OS,设定KMS Server到45.234 slmgr.vbs -skms 172.16.45.234 "Set KMS Server..." Start-Sleep -s 5 #判断KMS Server设定是否成功 $title = "The KMS Server" $message = "Set the KMS Server successfully?" $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes" $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No" $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no) $result = $host.ui.PromptForChoice($title, $message, $options, 0) switch ($result) { 0 { "Get key from KMS Server..." Slmgr.vbs -ato Start-Sleep -s 5 } 1 {"Set KMS server fail"} } #设定UAC到最低 "Set the UAC..." Set-ItemProperty -Path registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\policies\system -Name EnableLUA -Value 0 Start-Sleep -s 3 "UAC OK" #设定时区到China "Set the Time Zone..." tzutil /s "China Standard Time" "China Time Zone OK" Start-Sleep -s 2 #设定WUServer到GS的服务器 "Set the WUServer..." #自定义函数检测item function test-value($path,$item) { $item=Get-ItemProperty -Path $path -Name $item -ErrorAction SilentlyContinue return !($item -eq $null) } #自定义注册表赋值函数 function Set-RegistryValue($key, $name, $value) { if ((test-Path $key) -eq $null) {md registry::$key} if (test-value $key $name) {New-ItemProperty $key $name $value} else { Set-ItemProperty registry::$key $name $value } } #判断item是否存在,赋值 Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' 'WUServer' 'http://172.16.104.221' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' 'WUStatusServe' 'http://172.16.104.221' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' 'ElevateNonAdmins' '00000001' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' 'TargetGroupEnabled' '00000001' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate' 'TargetGroup' '' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'NoAutoUpdate' '00000000' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'AUOptions' '00000004' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'ScheduledInstallDay' '00000000' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'ScheduledInstallTime' '0000000a' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'UseWUServer' '00000001' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'AutoInstallMinorUpdates' '00000001' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'RebootRelaunchTimeoutEnabled' '00000001' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'RebootRelaunchTimeout' '0000000a' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'RescheduleWaitTime' '00000005' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'RescheduleWaitTimeEnabled' '00000001' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'NoAUShutdownOption' '00000001' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'NoAUAsDefaultShutdownOption' '00000001' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'DetectionFrequencyEnabled' '00000001' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'DetectionFrequency' '00000022' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'NoAutoRebootWithLoggedOnUser' '00000000' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'RebootWarningTimeout' '00000010' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU' 'RebootWarningTimeoutEnabled' '00000001' Set-RegistryValue 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run' 'WSUS Update' 'wuauclt.exe /detectnow' Start-Sleep -s 2 "WUServer OK" #下面绑定Gateway 的Mac地址 "Set the Gateway MAC..." "You can get vaild idx of connection network used from:" netsh i i show in # 据说这个是注释,这个是输入idx的对话框 [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") $objForm = New-Object System.Windows.Forms.Form $objForm.Text = "Data Entry Form" $objForm.Size = New-Object System.Drawing.Size(300,200) $objForm.StartPosition = "CenterScreen" $objForm.KeyPreview = $True $objForm.Add_KeyDown({if ($_.KeyCode -eq "Enter") {$x=$objTextBox.Text;$objForm.Close()}}) $objForm.Add_KeyDown({if ($_.KeyCode -eq "Escape") {$objForm.Close()}}) $OKButton = New-Object System.Windows.Forms.Button $OKButton.Location = New-Object System.Drawing.Size(75,120) $OKButton.Size = New-Object System.Drawing.Size(75,23) $OKButton.Text = "OK" $OKButton.Add_Click({$x=$objTextBox.Text;$objForm.Close()}) $objForm.Controls.Add($OKButton) $CancelButton = New-Object System.Windows.Forms.Button $CancelButton.Location = New-Object System.Drawing.Size(150,120) $CancelButton.Size = New-Object System.Drawing.Size(75,23) $CancelButton.Text = "Cancel" $CancelButton.Add_Click({$objForm.Close()}) $objForm.Controls.Add($CancelButton) $objLabel = New-Object System.Windows.Forms.Label $objLabel.Location = New-Object System.Drawing.Size(10,20) $objLabel.Size = New-Object System.Drawing.Size(280,30) $objLabel.Text = "Please enter the idx of of network used in the space below(You can get it from powershell screen):" $objForm.Controls.Add($objLabel) $objTextBox = New-Object System.Windows.Forms.TextBox $objTextBox.Location = New-Object System.Drawing.Size(10,70) $objTextBox.Size = New-Object System.Drawing.Size(260,20) $objForm.Controls.Add($objTextBox) $objForm.Topmost = $True $objForm.Add_Shown({$objForm.Activate()}) [void] $objForm.ShowDialog() $x #判断网段 $title = "The Gateway MAC" $message = "Which subnetwork this server in (Now supply 80~83/130~131 only)" $one = New-Object System.Management.Automation.Host.ChoiceDescription "&80~83" $two = New-Object System.Management.Automation.Host.ChoiceDescription "&130~131" $options = [System.Management.Automation.Host.ChoiceDescription[]]($one, $two) $result = $host.ui.PromptForChoice($title, $message, $options, 0) switch ($result) { 0 { netsh -c "i i" add neighbors $x "172.16.83.254" "00-23-89-17-a6-b6" Start-Sleep -s 2 } 1 { netsh -c "i i" add neighbors $x "172.16.131.254" "00-23-89-17-a6-b6" Start-Sleep -s 2 } } "Gateway MAC OK" Start-Sleep -s 2 import-Module ServerManager "Add Server Roles and Features..." Start-Sleep -s 2 "Server will restart..." Start-Sleep -s 3 Add-WindowsFeature Desktop-Experience,GPMC,Web-Server,RDS-RD-Server,Web-Asp-Net,Web-Windows-Auth,Web-Mgmt-Compat -Restart
查看全文
相关阅读:
Android logcat命令详解
使用Dom4j操作XML
最全面的常用正则表达式大全
struts.xml配置文件(package,namespace,action)
ActiveMQ入门实例
Windows Intel VT-x开启
Java ArrayList的不同排序方法
Hibernate面试问题集锦: 概述
10个有关String的面试问题
50道Java线程面试题
原文地址:https://www.cnblogs.com/Liangw/p/2559929.html
最新文章
linux在线安装telnet
linux 安装tar 命令
在Linux系统下统计当前文件夹下的文件个数、目录个数
在eclipse中new 对象后怎么通过快捷键自动生成返回对象
centos7开启网卡功能
Linux ./configure --prefix 命令是什么意思?
linux上mysql访问:Access denied for user 'agtipay'@'iZm5ebiyb4f90ga9xiycgsZ' (using password: YES)
eclipse上的.properties文件中文编辑显示处理
nginx监听端口转发到后端改变的问题
Spring定时任务传参问题 <property name="arguments"
热门文章
SSL 认证之后,request.getScheme()获取不到https的问题记录
sql相关函数
使用Hibernate Tools从数据库自动逆向生成Hibernate实体类
Spring中的注入方式
java 调用webservice接口
获取远程图片宽高
浏览器 下载远程地址服务器文件
重写equals和hashCode
一、初识java
1.微信公众平台开发概述
Copyright © 2011-2022 走看看