cmd批处理命令及powershell

Posted on   风行天下-2080  阅读(744)  评论(0编辑  收藏  举报

https://blog.csdn.net/wenzhongxiang/article/details/79256937

Powershell查询IP地址及主机名信息:
1.foreach($ipv4 in (ipconfig) -like '*IPv4*') { ($ipv4 -split ' : ')[-1]}
2.Get-WMIObject Win32_ComputerSystem |select Name
3.$env:COMPUTERNAME

4[net.dns]::GetHostAddresses('') | select -ExpandProperty IPAddressToString | select -index 5

批处理命令教程 https://www.cnblogs.com/YangGC/p/6345551.html

批处理变量和set命令详解          https://blog.csdn.net/actanble/article/details/59154972

批处理命令pop和push  https://blog.csdn.net/u010142437/article/details/72819692

批处理常用命令及用法大全 http://bbs.bathome.net/thread-39-1-1.html

批处理命令获取ip地址:

http://blog.51cto.com/hooden/1949416

powershell获取ip地址命令:

http://www.pstips.net/get-all-assigned-ip-addresses.html

[net.dns]::GetHostAddresses('') | select -ExpandProperty IPAddressToString

PS C:\Users\test001> [net.dns]::GetHostAddresses('') | select -ExpandProperty IPAddressToString | select -index 1


POWERshell命令讲解

https://www.cnblogs.com/lavender000/p/6935589.html

执行powershell脚本  

http://www.pstips.net/powershell-invoking-files-and-scripts.html

Powershell拥有自己的脚本,扩展名为“.ps1”

 powershell编写和运行脚本

http://www.pstips.net/powershell-create-and-start-scripts.html

POWERshell命令讲解

https://www.pstips.net/powershell-define-variable.html

 Powershell获取软件安装列表

http://www.pstips.net/get-installedsoftwares.html

cmd获取软件列表

https://zhidao.baidu.com/question/373838376559622324.html

python获取软件列表

http://blog.51cto.com/11072687/1752445

一键获取软硬件配置及管理员组

http://www.51testing.com/html/52/n-867352-3.html

bat常用命令

https://www.cnblogs.com/laislabonita/p/7145731.html

————————————————————————————————————————————————————

1、定义和使用变量   https://blog.csdn.net/flyoutsan/article/details/52811095

定义  set a=224

输出   echo  %a%

显示文件内容 type a.txt

 2、添加默认驱动器

c:\Users\Administrator>net use l: \\192.168.182.133\share "P@ssw0rd" /user:administrator
命令成功完成。

删除网络驱动器: net use H: /D

netuse命令用法 https://www.cnblogs.com/lhws/p/4024208.html

 3、直接yes确认,  末尾加/yes

c:\Users\Administrator>net use l: /D /yes
l: 已经删除。

 用例:

net use \\192.168.1.110 "P@ssword" /user:administrator
mkdir \\testzone\share\testooo
net use m: \\192.168.1.110\share "P@ssw0rd" /user:administrator
mkdir m:\mmm
copy c:\a.txt \\192.168.1.110\share
net use m: /D /yes

4、cmd命令结果赋值给变量

 for /f "tokens=*" %i in ('ipconfig /all^|find /i "ipv4" ') do set yourvar=%i

  for /f %i in ('date /t') do set youvar=%i

 5、分割字符串    https://blog.csdn.net/scimence/article/details/52808802

for /f "tokens=1 delims=/" %i in ('date /t') do set youvar=%i

for /f "tokens=2 delims=:" %i in ('ipconfig /all^|find /i "ipv4" ') do set yourvar=%i

分割变量   for /f "tokens=1 delims=(" %i in ("%yourvar%") do set bbb=%i

6、取某一行赋值  https://zhidao.baidu.com/question/1765977344186460500.html

@echo off
route print | findstr 0.0.0.0.*0.0.0.0 >bb.txt
for /f "tokens=1* delims=:" %%i in ('type bb.txt^| findstr /n ".*"') do (
If "%%i"=="1" Set key=%%j
)
echo %key% >>bb.txt

 获取ip地址,必须以bat格式运行才能正确获取               http://www.cnblogs.com/xwdreamer/p/3848703.html

获取ip地址的两种方法,未测试。                  https://www.jb51.net/article/52745.htm

win2008获取ip地址        http://www.bathome.net/thread-30657-1-1.html

变量的分割,截取,拼接         https://blog.csdn.net/albertsh/article/details/52797519

字符串的截取

@echo off
set str=" 0.0.0.0 0.0.0.0 10.116.0.6 10.116.0.248 266"
echo str = %str%
for /f "tokens=4 delims= " %%a in (%str%) do (
echo %%a >dd.txt

)
pause

 7、Tokens的详细用法

https://www.cnblogs.com/frankcui/p/11630160.html#_label2

编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?

随笔 - 618, 文章 - 0, 评论 - 6, 阅读 - 37万

Copyright © 2025 风行天下-2080
Powered by .NET 9.0 on Kubernetes

点击右上角即可分享
微信分享提示