Scripts-脚本

PowerShell的常用命令I

2023年2月16日 klaus.xie 1 min read

快速查找在域控的电脑,尤其是改电脑名字之后,在域控找不到新的电脑名字:

Get-ADComputer -Filter {serviceprincipalname -like "*boron*"} | select *

快速复制用户所属组

$getusergroups = Get-ADUser -Identity klaus.xie -Properties memberof | Select-Object -ExpandProperty memberof #引用变量,查询要复制用户的所属组
$getusergroups | Add-ADGroupMember -Members kobe.bryant -verbose #把变量的组加到新用户
Get-ADUser -Identity kobe.bryant -Properties memberof | Select-Object -ExpandProperty memberof #查询新用户的组是不是已经加好

Copy AD Group Membership to Another User in PowerShell | Windows OS Hub (woshub.com)

Get-ADGroupMember -Identity “Finance” | select name | Export-Csv -Path “C:\temp\Finance.csv” -NoTypeInformation # Export the members of group<< ESXI密令建删除快照

  • 测试跟远程电脑的某个端口是否通,尤其是防火墙配置开放了某个端口:
Test-NetConnection -ComputerName 8.8.8.8 -Port 3389

Test-NetConnection -ComputerName 2001:db8:3333:4444:5555:6666:7777 -Port 3389

Leave a comment