Windows Server - Redirecting Output of Script
Asked By David Eisner
24-Oct-08 04:16 AM

I must be missing something basic. I have a simple script that calls
an external command (subinacl):
$homeMapFile = "C:\VOL\AD\data\ad_user_homes.csv"
$prefix = "M:\"
Import-CSV -path $homeMapFile |
foreach-object {
$homeDir = $prefix + $_.HOME_DIR
& subinacl /file $homeDir /display=owner
}
The script is saved in "set_permissions.ps1" So now I want to redirect
all the output to a log file. I believe this should do what I want:
.\set_permissions.ps1 > output.txt 2>&1
But what happens is this:
1. The output is still displayed to the console.
2. The output is also placed in output.txt, but with a space between
every character, like so:
+ F i l e M : \ H O M E \ O F F I C E \ J O A N Y U A N
/ o w n e r = b u i l t i n \ a d m
i n i s t r a t o r s
Upon further examination, the spaces are actually three null bytes.
So the file really looks like ... 'F', '\0', '\0', '\0', 'i',
'\0', ...
What's going on? Is this some type of encoding issue? I'd be happy
with UTF-8 by default.
Thanks in advance.
-David
BigEndianUnicode
(1)
HomeMapFile
(1)
Frameworks
(1)
Specifies
(1)
Director
(1)
HomeDir
(1)
Subinacl
(1)
Foreach
(1)
Marco Shaw [MVP] replied...
There's a microsoft.public.windows.powershell group that would be more
helpful with PowerShell questions.
The out-file cmdlet has an encoding parameter:
PS>help out-file -full
...
-Encoding <string>
Specifies the type of character encoding used in the file. Valid
values are "Unicode", "UTF7", "UTF8", "UTF32",
the default.
...
Marco
--
*Microsoft MVP - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
appended to the CA name. I only see the following unattended answer file settings. CAType Specifies the type of CA to install. CSPProvider Specifies the name of the Cryptography Service Provider (CSP). HashAlgorithm Specifies the hash algorithm used by the CA to sign certificates. KeyLength Specifies the key length for the CA. Name Specifies the name of the CA. ParentCAMachine Specifies the computer name with a CA that works as a parent CA with the current subordinate CA installation. ParentCAName Specifies the parent CA name for the current subordinate CA installation. SharedFolder Specifies the path to the folder that contains the configuration information for the CA. UseSharedFolder Specifies
and access the ; Active Directory on that domain controller. ; DomainControllerForSourceServer = PG ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; SrcServerLDAP-Port ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This entry specifies the port number to be used when trying to access the directory (Exchange 5.x controller and access the ; Active Directory on that domain controller. ; DomainControllerForDestServer = ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; DestServerLDAP-Port ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This entry specifies the port number to be used when trying to access the directory (Exchange 5.x folders ; 1 - Apply action to sub folders ; ; Default Value: 0 ; ApplyActionToSubFolders = 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; DelimiterUsedInMailboxFile ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This setting specifies which delimiter should be used to distinguish between the source ; and target DNs in the applicable when running the program in Batch mode. ; ; Default Value: Blank FileContainingListOfDatabases = ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;RestoreDB ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This setting specifies whether you are extracting data from a restored database (RestoreDB = 1) or a ; non-restored C: \ Program Files \ Microsoft Integration \ Windows Small Business Server 2003 \ MAILBOXES.TXT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; DateAttribute ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This setting specifies which date attribute the program should use when extracting items ; by date. ; This setting is the program in batch mode. ; ; Default Value: ; ; Example: ; UseThisPSTFileForAllMailboxes = DataToBeImported.PST ; UseThisPSTFileForAllMailboxes = ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; StartingIndex ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This setting specifies the index in the list of mailboxes, at which to start processing. ; The list of setting could have a value from 0 onwards. ; ; Default Value: 0 ; StartingIndex = ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; EndingIndex ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This setting specifies the last index, in the list of mailboxes, which will be processed. ; This setting is Posteingang ; Delete Items = Geloschte Objekte ; Sent Items = Gesendete Objekte ; Outbox = Postausgang [International] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;DefaultLocaleID ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This setting specifies the Default Locale that the program should use ; when it logs onto mailboxes. If this
rights and now if you go under Documnets and settings, he has 3 folders: maintenance director maintenance director.MAINTENANCE maintenance director.MAINTENANCE.000 I found the files under the 1st folder (I guess the one he know if it worked. Pegasus. . . . I run the commands you said and I have: maintenance director maintenance director.MAINTENANCE maintenance director.MAINTENANCE.000 you wrote to the other guy the following: recent date? This would be Now, it looks to me that the most recent folder was the last one (maintenance director.MAINTENANCE.000). . . did you say that this one is the correct folder???? shouldnt it be the first one (maintenance director)? I dont want to do anything weird here, that is why I guess I need
MOUNTVOL [drive:]path / L MOUNTVOL [drive:]path / P MOUNTVOL / R MOUNTVOL / N MOUNTVOL / E path Specifies the existing NTFS directory where the mount point will reside. VolumeName Specifies the volume name that is the target of the mount point. / D Removes the volume MOUNTVOL [drive:]path / L MOUNTVOL [drive:]path / P MOUNTVOL / R MOUNTVOL / N MOUNTVOL / E path Specifies the existing NTFS directory where the mount point will reside. VolumeName Specifies the volume name that is the target of the mount point. / D Removes the volume MOUNTVOL [drive:]path / L MOUNTVOL [drive:]path / P MOUNTVOL / R MOUNTVOL / N MOUNTVOL / E path Specifies the existing NTFS directory where the mount point will reside. VolumeName Specifies the volume name that is the target of the mount point. / D Removes the volume MOUNTVOL [drive:]path / L MOUNTVOL [drive:]path / P MOUNTVOL / R MOUNTVOL / N MOUNTVOL / E path Specifies the existing NTFS directory where the mount point will reside. VolumeName Specifies the volume name that is the target of the mount point. / D Removes the volume
XP Download details: Windows Script 5.7 for Windows Server 2003 - - Michael Harris MVP - Admin Frameworks Do we get anything new or interesting from this version? No new features that I are more in sync with the WSH version included with Vista. - - Michael Harris MVP - Admin Frameworks [Michael Harris (MVP)] wrote-: Thanks for the info and link. :) Good Luck, Ayush. - - Scripting Solutions you mean as a Windows automatic update, I seriously doubt it. - - Michael Harris MVP - Admin Frameworks Michael Harris (MVP) said the following on 8 / 9 / 2007 9:56 PM: Do you of, but then I am not exactly privy to their plans :-). . . - - Michael Harris MVP - Admin Frameworks Michael Harris (MVP) said the following on 8 / 15 / 2007 4:26 PM: I wouldn to different SFP (System File Protection) requirements for OS component installs. - - Michael Harris MVP - Admin Frameworks That doesn't explain why 5.6 and previous versions were removed - that means that agree with you 100% but unfortunately cannot offer any explanation (yet). . . - - Michael Harris MVP - Admin Frameworks Looked at it. Resembles a shaped statement out of the ado book. msdatashape or so SFP (System File Protection) requirements for OS component installs. - - Michael Harris MVP - Windows Server Admin Frameworks Release Notes. . . http: / / download.microsoft.com / download / f / f / e / ffea3abf-b55f-4924-b5a5-bde0805ad67c