PowerShell 相关常用命令(update...)
# PowerShell提示系统禁止执行脚本解决方法(报错提示)
## 获得当前的执行策略
Get-executionpolicy
>> Bypass 策略完全不限制
>> Restricted 策略不允许任何脚本运行
>> AllSigned 可以运行脚本,但要求所有脚本和配置文件由可信发布者签名,包括在本地计算机上编写的脚本。
>> RemoteSigned 可以运行脚本,但要求从网络上下载的脚本和配置文件由可信发布者签名; 不要求对已经运行和已在本地计算机编写的脚本进行数字签名。
>> Unrestricted 可以运行未签名脚本。(危险!)
>> Undefined 表示运行级别尚未定义。但此时实际是执行上面提到的系统默认运行级别。
## 修改当前执行策略
Set-ExecutionPolicy RemoteSigned (管理员方式执行Powershell)
【远程相关】
## 查看TrustedHost列表
gci wsman::localhost\client\trustedhosts
## 添加TrustedHost列表
Set-item wsman:localhost\client\trustedhosts –value * # 允许自己访问所有
Set-item wsman:localhost\client\trustedhosts –value sever1,server2 # 允许自己访问别人de计算机名
Set-item wsman:localhost\client\trustedhosts –value *.testj.com # 允许自己访问的域名
Set-item wsman:localhost\client\trustedhosts –value 192.168.X.X # 允许自己访问的IP地址
PS:如果自己谁都不允许
Set-item wsman:localhost\client\trustedhosts –value -
# 远程其他电脑的PS
需要开启端口:5985
Enable-PSremoting/Disable-PSremoting # 启动允许PS远程,且网络位置不能被设置为public,因为Windows 防火墙例外不能在网络位置是public时被启用。
test-wsman -computername localhost # 测试服务器上的WINRM服务是否在运行
Enter-PSSession X.X.X.X -Credential administrator # 远程X.X.X.X 电脑的PS
## 关闭PS远程
Disable-PSremoting # 关闭
Set-Service winrm -StartupType Manual # 服务设置为手动
Stop-Service winrm # 停止服务
# 移除默认情况下WinRM在5985端口设置的监听器
Get-ChildItem WSMan:\localhost\Listener –Recurse | Foreach-Object { $_.PSPath } | Where-Object { (Get-Item "$_\Port").Value -eq 5985 } | Remove-Item
## 查看WinRM正在侦听的特定IP:
winrm enumerate winrm/config/listener Or winrm e winrm/config/listener
## 修改WinRM端口
WinRM默认的http端口是5985,https端口5986
winrm set winrm/config/listener?Address=+Transport=HTTP ‘@{Port=“1212”}’
或 set-item wsman:\localhost\listener\listener\port 1212
相关文章
- 数据库存储过程相关知识
- MySQL查看数据库相关信息
- slam相关知识
- 如何得到ABAP Webdynpro PDF渲染的性能相关文件
- SAP Spartacus和product相关的标准normalizer
- SAP 电商云 Spartacus UI Store 相关的设计明细
- 【操作系统笔记02】操作系统之多线程模型、处理机调度及其相关调度算法
- ML:机器学习中与模型相关的一些常见的判断逻辑(根据自调整阈值计算阳性率)
- 【阶段二】Python数据分析Pandas工具使用09篇:探索性数据分析:数据的描述:数据的相关关系与数据的波动趋势
- PHP 零基础入门笔记(13):数组相关函数
- Linux 介绍了相关的文件夹
- debian vim 相关
- LabVIEW编程LabVIEW开发McPherson Model 747例程与相关资料
- LabVIEW编程LabVIEW控制Agilent 5313X例程与相关资料
- 第二人生的源码分析(五十七)OpenGL离屏渲染的相关函数