Jump to content

Recommended Posts

Posted

Hello

Can someone help me debug this script? :) Need a script to read a CSV and run a command to add print credit to users.

 

I've given an example command line which works.

 

Thanks

 

 

 


$Users  = Import-Csv -Path "$env:USERPROFILE\Desktop\credit.csv"

ForEach ($User in $Users)
{
   $Parameters = @{
       Credit = $User.Credit
       Comment = $User.Comment
       User = $User.Username
   }

    Write-host @Parameters

#    "c:\Program Files\PaperCut MF\server\bin\win\server-command.exe adjust-user-account-balance" @Parameters

# EXAMPLE command with parameters "c:\Program Files\PaperCut MF\server\bin\win\server-command.exe" adjust-user-account-balance "TESTUSER" 1.00 "Add £1"

}

Posted

When you Write-Host them I'd imagine they come out in a different order each time it's ran? You'll need to use an Ordered hashtable to fix that or not bother with the hashtable at all and just specify them in the command line, possibly in a format like this:

 

& "c:\Program Files\PaperCut MF\server\bin\win\server-command.exe adjust-user-account-balance" "$($User.Username) $($User.Credit) $($User.Comment)"

 

I'd probably use this method as I recall spaltting a hashtable into command tags on the full hashtable including parameter names so that might be screwing it up.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...