我的第一篇博客分享,写这个代码的用途是在公司Ghost完系统之后去修改本地计算机名称及IP 地址,用Powershell实现. 1. 代码第一部分,检查Powershell是否已管理员权限执行,如果不是的话,强制以管理员权限开启一个powershell窗口. #region Key code: force to run with administrator rights $currentWi = [Security.Principal.WindowsIdentity]::GetCurrent()
实验设备: 二层交换机一台,主机三台 实验步骤: 1.进入相应的接口 (以端口1设置Mac地址绑定,PC0接1端口举例) Switch>enable Switch#config Configuring from terminal, memory, or network [terminal]? Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#Switch(config)#interface fa
获取计算机名 # 获取计算机名,常用的方法有三种 import os import socket # method one name = socket.gethostname() print(name) # DESKTOP-S3BGVQN # method two name = os.popen("hostname").read() print(name) # DESKTOP-S3BGVQN # method three name = os.environ.get("COMP