fan*_*lla 10 windows powershell batch-file fqdn
我想要做的是保存powershell命令的输出(从批处理脚本运行)并在批处理脚本中使用它.
你能告诉我该怎么办?
电源外壳命令是:
[System.Net.Dns]::GetHostByName((hostname)).HostName
Run Code Online (Sandbox Code Playgroud)
我想在批处理脚本中使用输出.
如果我可以从cmd获取完整的计算机名/主机名/完全限定的域名(FQDN)而不是PowerShell,那将会更好.但完整的计算机名称不是ComputerName和UserDNSDomain变量的串联.
Ste*_*han 11
for /f "tokens=*" %%i in ('powershell /command "[System.Net.Dns]::GetHostByName((hostname)).HostName"') do set return=%%i
echo %return%
Run Code Online (Sandbox Code Playgroud)