Question out-file error

Plus d'informations
il y a 10 ans 7 mois #15685 par julien
out-file error a été créé par julien
<br><br>Message édité par: julien_pw, à: 22/08/13 11:02

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

Plus d'informations
il y a 10 ans 7 mois #15739 par hahang
Réponse de hahang sur le sujet Re:out-file error
Voici un exemple de script utilisant le cmdlet out-file ( powershell.nicoh.me/powershell-1/active-...ibutes-from-csv-file ) :

[code:1]$csv = Get-Content c:\folder\file.csv
foreach ($string in $csv) {
$username = $string.split(\&quot;;\&quot;«»)[2]
$tel = $string.split(\&quot;;\&quot;«»)[4]
$mobile = $string.split(\&quot;;\&quot;«»)[3]
$username + \&quot;`t : \&quot; + (Get-QADObject -Type User -SizeLimit 0 -Identity $username -Properties telephonenumber).telephonenumber + \&quot;`t/`t\&quot; + (Get-QADObject -Type User -SizeLimit 0 -Identity $username -Properties mobile).mobile | Out-File -FilePath (\&quot;c:\folder\change.log\&quot;«») -encoding ASCII -append -Width 1000
if ($mobile -eq \&quot;NULL\&quot;«») {
Set-QADUser -Identity $username -PhoneNumber $tel -MobilePhone $null
}
else {
Set-QADUser -Identity $username -PhoneNumber $tel -MobilePhone $mobile
}
\&quot;`t &gt; NEW ENTRY for \&quot; + $username + \&quot;`t : \&quot; + (Get-QADObject -Type User -SizeLimit 0 -Identity $username -Properties telephonenumber).telephonenumber + \&quot;`t/`t\&quot; + (Get-QADObject -Type User -SizeLimit 0 -Identity $username -Properties mobile).mobile | Out-File -FilePath (\&quot;c:\folder\change.log\&quot;«») -encoding ASCII -append -Width 1000
}[/code:1]

My Powershell IT Script Library powershell.nicoh.me

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

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