Different formatting

Mikhail Firsov 1,876 Reputation points
2020-12-09T10:59:10.097+00:00

Hello,

Strange problem: I have a script that reads an object's ACL and saves it to a text file (Get-Acl objectname -Audit |FL > "textfile.txt"). Script has been working fine until I've bumped into the weird issue - occasionally the format of the resulting txt file is different from the one created previously (as I need to compare the old and the new files this leads to the false triggering), for example, if I run the script 6 times in a raw the format of the Sddl section will look as in the blue rectangle, but the 7th will look like in the red:

46494-q3.png

It does not matter whether there were any changes in ACLs or not - the format of SDDL strings can change without any (at least noticable) reason.

The two files do differ in formatting...
46651-q1.png

...but not in the content:
46661-q2.png

I've spent more than two days trying to pinpoint the situation in which those changes occur but to no avail, I just found out that the format may change any time in any way: it can change during the last 7 minutes or only the day after the script was run for the first time. The Sddl section may be made of 4-5-6 short strings, may be of 3-4 long ones. What can affect the way the PS formats a file???

Thank you in advance,
Michael

Windows Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
3,480 questions
Windows Server 2016
Windows Server 2016
A Microsoft server operating system that supports enterprise-level management updated to data storage.
2,389 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
0 comments No comments
{count} votes

8 answers

Sort by: Most helpful
  1. Mikhail Firsov 1,876 Reputation points
    2020-12-11T14:56:30.503+00:00

    ...the last point... :

    47424-11.png

    47444-12.png

    ...it just does not work.

    Thank you all for your help!

    Regards,
    Michael

    0 comments No comments

  2. Mikhail Firsov 1,876 Reputation points
    2020-12-11T15:22:07.55+00:00

    P.S.

    And the cherry on the cake:

    47378-13.png

    As you see on the screenshot above the files were copied to C:\111 (and first compared) at 2:21 PM. I've been running this code since that time ~ 10 times (at ~3:00PM, 3:30PM, 16:05, ...18:03PM), the result was False. At 18:07 the result became True. The question is closed.

    0 comments No comments

  3. Mikhail Firsov 1,876 Reputation points
    2020-12-18T08:41:13.513+00:00

    Hi BillStewart,

    "I think it would help if you view formatted output as convenient for viewing but not for further processing. Another way to say this is: If you want to do something with the data, select the properties you want directly (don't use the formatting cmdlets for that use case)." - I guess you're right.

    But it means that this -
    "The format cmdlets, such as Format-List, arrange the data to be displayed but do not display it. The data is displayed by the output features of PowerShell and by the cmdlets that contain the Out verb (the Out cmdlets), such as Out-Host or Out-File. "

    • is not true because - according to the statements above - arranging the data should not affect the "the output features of PowerShell", especially when you run the same command several times.

    Regards,
    Michael