Question Problème de syntaxe

Plus d'informations
il y a 17 ans 4 mois #3030 par PASCAULT
Réponse de PASCAULT sur le sujet Re:Problème de syntaxe
Bonjour,

DNSServerSearchOrder et DNSDomainSuffixSearchOrder sont tous les 2 des collections d'objets.
Il faut donc que tu parcours ce \"tableau\". Pour tester, tu peux essayer DNSServerSearchOrder[0]

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 17 ans 4 mois #3031 par Grégory
Réponse de Grégory sur le sujet Re:Problème de syntaxe
Gaffe il manque des / dans tes chemins dans ton premier post ;)

sinon j'ai testé, ça marche sans problème

[code:1]
$PCs=Get-Content \"C:\PWRSHELLlistPC.txt\"
foreach ($PC in $PCs){
$ColItems = get-wmiobject -class \"Win32_NetworkAdapterConfiguration\" `
-ComputerName $PC | where{$_.IpEnabled -match \"True\"}

foreach ($objItem in $colItems) {
$PC, $objItem.IPAddress, $objItem.MACAddress, $objItem.DNSServerSearchOrder,$objItem.DNSDomainSuffixSearchOrder,\"`r`n\"| Format-List | out-file \"c:\PWRSHELLipaddress.txt\" -Append -NoClobber
}
}[/code:1]

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 17 ans 4 mois #3032 par PASCAULT
Réponse de PASCAULT sur le sujet Re:Problème de syntaxe
cela marche effectivement bien comme le propose Nostra.
sans l'utilisation du formatage -f.
Si tu veux conserver son utilisation, il faut alors convertir ton tableau en string.

[code:1]\"Nom:{0} Ip:{1} DnsSearch:{2} DnsSuffixeSearch:{3}\" -f $PC,$objitem.ipaddress,$objitem.DNSServerSearchOrder[0],[string]$objItem.DNSDomainSuffixSearchOrder[/code:1]

Dans cet exemple, ipaddress devrait te donner System.String[] puisque c'est possible d'avoir plusieurs ip donc une collection.
$objitem.DNSServerSearchOrder[0] :le DNS préféré
[string]$objItem.DNSDomainSuffixSearchOrder : la collection complète de suffixe de recherche DNS

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.076 secondes
Propulsé par Kunena