powershell - Generate fully qualified host names -
powershell - Generate fully qualified host names -
i need qualify hostnames not currently.
h284infa.txt contains qualified domain names , not within // /.
h284infalist.ps1 holds host names domain separated = sign.
i need pull list h284infa.txt qualify ids not , write output output.txt. not lines below right currently. on sec lastly line need command pull info between 2 documents.
$data = get-content "h284infa.txt" $stream = [system.io.streamwriter] "output.txt" foreach ($line in $data) { $var = (($var -split ("\\\\"))[1]) $var = (($var –split ("\\"))[0]).tolower if var "empty" if ($var -eq ".com") { if var if ($var -notlike ".com") { $data1 = get-content "h284infalist.ps1" | select-string $var $hostname = (($line -split ("="))[0]).tolower() $fqdn = ($hostname + "." + ($line -split ("="))[1]).tolower() $c=$line1.tolower() -replace $var, $fqdn $stream.writeline($c) } else { "pull line file file b" $stream.close()
something should want:
$host2fqdn = @{} get-content 'c:\path\to\h284infalist.ps1' | % { $hostname, $fqdn = $_ -split '\s*=\s*' $host2fqdn[$hostname] = $fqdn } (get-content 'c:\path\to\h284infa.txt') | % { if ( $_ -match '\\\\(.+?)\\' -and $host2fqdn[$matches[1]] ) { $_ -replace $matches[1], $host2fqdn[$matches[1]] } else { $_ } } | set-content 'c:\path\to\h284infa.txt' powershell powershell-v1.0
Comments
Post a Comment