windows server常用操作

 


【1】基本操作

netsh 修改IP地址和DNS

Rem 设置名称叫 本地连接的网卡,静态地址为 192.168.0.1 后面是子网掩码、网关netsh interface ip set address "本地连接" static 192.168.0.1 255.255.255.0 192.168.0.254 1    
Rem 设置名称叫 本地连接的网卡 DNS 为 202.194.40.1,第2行的 add dns 为添加第二DNS
netsh interface ip set dns "本地连接" static 202.194.40.1
netsh interface ip add dns "本地连接" 202.194.40.2 2Rem 设置名称叫 本地连接的网卡 其IP地址模式为 DHCP 分配netsh interface ip set address "本地连接" dhcp

wmic修改计算机名

wmic computersystem where "name='%computername%'" call rename "Someyouwana"

Rem netdom 也可以,但这是交互式的
netdom /renamecomputer %computername% /newname:input_new_computer_name

netdom join 加入,退出域

复制代码
复制代码
NETDOM JOIN machine /Domain:domain [/OU:ou path] [/UserD:user]
           [/PasswordD:[password | *]]
           [UserO:user] [/PasswordO:[password | *]]
           [/REBoot[:Time in seconds]]

 
NETDOM REMOVE machine /Domain:domain [/UserD:user]
           [/PasswordD:[password | *]]
           [UserO:user] [/PasswordO:[password | *]]
           [/REBoot[:Time in seconds]]
复制代码
复制代码

案例:加入、退出域

@echo off
netdom join %computername% /domain:tech.com /UserD:tech\administrator /PasswordD:ASD!@#123 /REBoot:5

@echo off
netdom remove %computername% /domain:tech.com /UserD:tech\administrator /PasswordD:ASD!@#123 /REBoot:5

ps:get/install/remove-windowsfeature 安装,查看,卸载角色、角色服务、功能

get-Windowsfeature Name,要是不写name就是全部,写name就是制定的服务
add-WindowsFeature Name -whatif,模拟安装这个服务可能发生的情况,以及是否需要重启之类的,但实际上不会进行任何操作
Install-WindowsFeature -name name1,name2 -Restart # 安装功能 name1,name2 这里可以写多个,以逗号分隔,如该行例子,-Restart 是安装完后自动重启,可以去掉该参数
remove-WindowsFeature name # 卸载功能

-whatif :模拟执行,检查、查看情况,并没有实际执行
-Restart :执行命令完后,重启计算机

 

get-windowsfeature  name,要是不写name就是全部,写name就是制定的服务

      

  

add-windowsfeature name -whatif,模拟安装这个服务可能发生的情况,以及是否需要重启之类的,但实际上不会进行任何操作

remove-windowsfeature name -whatif

  

 

 

 install-windwsfeature name , remove-windowsfeature name

  

 

 

get/set-executionpolicy 查看/设置 PS脚本是否允许执行

get-executionpolicy    # Unrestricted,Restricted
set-executionpolicy Unrestricted/Restricted

 

PS:dir env:/Get-Childitem env: 查看获取windows环境变量

  

 

 

 怎么获取呢?

  PS:$env:computername   DOS: %computername%

   

 

posted @   郭大侠1  阅读(885)  评论(0编辑  收藏  举报
编辑推荐:
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
历史上的今天:
2018-12-04 sql server自动化备份运维脚本
点击右上角即可分享
微信分享提示