![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | end of line while processing a string token issue I have this piece of code and can't figure out why it gives me this error every time. PS C:\Tools\Scripts> .\getusers.ps1 Encountered end of line while processing a string token. At C:\Tools\Scripts\getusers.ps1:108 char:30 + + $v30 + "," + $v31 + "," <<<< + $v32 Code; $tempfile = "c:\temp.txt" function Clean-Vars { $v1 = ""; $v2 = ""; $v3 = ""; $v4 = ""; $v5 = ""; $v6 = ""; $v7 = ""; $v8 = ""; $v9 = ""; $v10 = ""; $v11 = ""; $v12 = ""; $v13 = ""; $v14 = ""; $v15 = ""; $v16 = ""; $v17 = ""; $v18 = ""; $v19 = ""; $v20 = ""; $v21 = ""; $v22 = ""; $v23 = ""; $v24 = ""; $v25 = ""; $v26 = ""; $v27 = ""; $v28 = ""; $v29 = ""; $v30 = ""; $v31 = ""; $v32 = "" } $allusers = get-adobject -domain mcd.pri -pagesize 500 -filter "(&(mailNickname=*)(objectclass=user)) Clean-Vars foreach ($one in $allusers) { $usrs = $usrs + 1 $v1 = $one.objectclass[1] $v2 = $one.cn $v3 = $one.msExchHomeServerName.tostring() $v3 = $v3.split('=')[5] $v4 = $one.MDBOverquotalimit $v5 = $one.mDBUseDefaults $v6 = $one.mDBOverHardQuotaLimit $v7 = $one.mailnickname $v8 = $one.whencreated.tostring() $v9 = $one.whenchanged.tostring() $v10 = $one.sAMAccountName $v11 = $one.givenname $v12 = $one.sn $v13 = '"' + $one.displayname + '"' $v14 = $one.userprincipalname $v15 = $one.mail $v16 = $one.proxyaddresses $v17 = $one.ou $v18 = $one.msexchhidefromaddresslists $v19 = $one.altrecipient $v20 = $one.extensionattribute1 $v21 = $one.deliverandredirect $v22 = $one.admindescription $v24 = $one.telephoneNumber $v25 = $one.pager $v29 = '"' + $one.memberof + '"' $v30 = $one.department $v31 = $one.tittle # $vtot = $v1 + "," + $v2 + "," + $v3 + "," + $v4 + "," + $v5 + "," + $v6 + "," + $v7 + "," + $v8 + "," + $v9 + "," + $v10 + "," + $v11 + "," ` + $v12 + "," + $v13 + "," + $v14 + "," + $v15 + "," + $v16 + "," + $v17 + "," + $v18 + "," + $v19 + "," + $v20 + "," ` + $v21 + "," + $v22 + "," + $v23 + "," + $v24 + "," + $v25 + "," + $v26 + "," + $v27 + "," + $v28 + "," + $v29 + "," ` + $v30 + "," + $v31 + "," + $v32 add-content $tempfile $vtot $vtot = "" Clean-Vars } Any help will be appreciated. Hector |
| | #2 (permalink) | ||||||||||||
| Guest | Re: end of line while processing a string token issue What is your end goal? Why are you trying to clean-up the variables? What are you expecting the output to look like? "hectoritnt" <hectoritnt@xxxxxx> wrote in message news:1190993581.745539.310020@xxxxxx
| ||||||||||||
| | #3 (permalink) | ||||||||||||
| Guest | Re: end of line while processing a string token issue As a note... If you decide to stick with the cleanup option... there is much better way IMO function Clean-Vars{ Param($Filter) get-ChildItem variable: | Where-Object{$_.Name -match $filter} | remove-Variable -whatif } The filter in this case would be "^v\d" I would recommend using a variable naming scheme that is more precise like myTmpVarX then the filter would be "^myTmpVar\d" "hectoritnt" <hectoritnt@xxxxxx> wrote in message news:1190993581.745539.310020@xxxxxx
| ||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Guest | Re: end of line while processing a string token issue On Sep 28, 12:17 pm, "Brandon Shell" <tshell.m...@xxxxxx> wrote:
5.5 days because it's being used as input for some external processes. I'm cleaning the variables to make sure I don't carry unwanted data. It is not meant to be part of the final product. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Guest | Re: end of line while processing a string token issue It looks like the dump is suppose to be a CSV.. correct? Have you looked at export-csv cmdlet. "hectoritnt" <hectoritnt@xxxxxx> wrote in message news:1190998457.839673.120640@xxxxxx
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | #6 (permalink) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Guest | Re: end of line while processing a string token issue Can you try this? It will not require cleaning up anything. btw... I figured out your original problem.. missing " at the end of filter "(&(mailNickname=*)(objectclass=user)) #<<<< ############################## $tempfile = "c:\temp.txt" $allusers = get-adobject -domain corp.bloomberg.com -pagesize 500 -filter "(&(mailNickname=*)(objectcategory=user))" $myObjCol = @() foreach ($one in $allusers) { $usrs = $usrs + 1 $myobj = "" | Select-Object ObjectClass,cn,msExchHomeServerName,val,MDBOverquotalimit,mDBUseDefaults, mDBOverHardQuotaLimit,mailnickname,whencreated,whenchanged, sAMAccountName,givenname,sn,displayname,userprincipalname, mail,proxyaddresses,ou,msexchhidefromaddresslists,altrecipient, altrecipient,extensionattribute1,deliverandredirect,admindescription, telephoneNumber,pager,memberof,department,title $myobj.ObjectClass = $one.objectclass[1] $myobj.cn = $one.cn $myobj.msExchHomeServerName = $one.msExchHomeServerName.tostring() $myobj.val = ($myobj.msExchHomeServerName).split('=')[5] $myobj.MDBOverquotalimit = $one.MDBOverquotalimit $myobj.mDBUseDefaults = $one.mDBUseDefaults $myobj.mDBOverHardQuotaLimit = $one.mDBOverHardQuotaLimit $myobj.mailnickname = $one.mailnickname $myobj.whencreated = $one.whencreated.tostring() $myobj.whenchanged = $one.whenchanged.tostring() $myobj.sAMAccountName = $one.sAMAccountName $myobj.givenname = $one.givenname $myobj.sn = $one.sn $myobj.displayname = '`"' + $one.displayname + '`"' $myobj.userprincipalname = $one.userprincipalname $myobj.mail = $one.mail $myobj.proxyaddresses = $one.proxyaddresses $myobj.ou = $one.ou $myobj.msexchhidefromaddresslists = $one.msexchhidefromaddresslists $myobj.altrecipient = $one.altrecipient $myobj.extensionattribute1 = $one.extensionattribute1 $myobj.deliverandredirect = $one.deliverandredirect $myobj.admindescription = $one.admindescription $myobj.telephoneNumber = $one.telephoneNumber $myobj.pager = $one.pager $myobj.memberof = '`"' + $one.memberof + '`"' $myobj.department = $one.department $myobj.title = $one.title $myObjCol += $myobj } $myObjCol | export-Csv $tempfile ############################# "hectoritnt" <hectoritnt@xxxxxx> wrote in message news:1190998457.839673.120640@xxxxxx
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||