首页 > 系统服务 > 详细

修改Linux hostname

时间:2019-08-01 10:58:42      阅读:83      评论:0      收藏:0      [点我收藏+]
$keyFile = "D:\vm\linux.key"
$key = New-Object Byte[] 32
$key | out-file $keyFile

Read-Host "Enter Password" -AsSecureString | ConvertFrom-SecureString -key $key | Out-File "D:\vm\linux.txt"

$userName = "root"
$passwdFile = "D:\vm\linux.txt"
$keyFile = "D:\vm\linux.key"
$key = Get-Content $keyFile
$Cred = New-Object -TypeName System.Management.Automation.PSCredential `
-ArgumentList $userName, (Get-Content $passwdFile | ConvertTo-SecureString -Key $key)

$vms = Get-Content D:\VM\vm2.txt

echo $vms

foreach ($vm in $vms)

{

$st = "hostnamectl set-hostname $vm"

Invoke-VMScript -VM $vm -ScriptType Bash -ScriptText $st -GuestCredential $Cred

}

修改Linux hostname

原文:https://blog.51cto.com/littlebamboo/2425362

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!