question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Formatting Problem for Security.Principal.WindowsPrincipal( [Security.Principal.WindowsIdentity]::GetCurrent() )

See original GitHub issue

System Details

  • Operating system name and version - Windows 10.0.18363 Build 18363
  • VS Code version - 1.48.2
  • PowerShell extension version - v2020.6.0
  • Output from $PSVersionTable

To get this information, run the following expression in your Integrated Console and paste the output here inside the backticks below:

& {“### VSCode version: $(code -v)”; “n### VSCode extensions:n$(code --list-extensions --show-versions | Out-String)”; “n### PSES version: $($pseditor.EditorServicesVersion)"; "n### PowerShell version:`n$($PSVersionTable | Out-String)”}

System Details Output

### VSCode version: 1.48.2 a0479759d6e9ea56afa657e454193f72aef85bd0 x64

### VSCode extensions:
4ops.terraform@0.1.10
aaron-bond.better-comments@2.1.0
alefragnani.project-manager@11.3.0
amazonwebservices.aws-toolkit-vscode@1.13.0
batisteo.vscode-django@0.20.0
bibhasdn.git-easy@1.11.0
chrmarti.regex@0.2.0
codezombiech.gitignore@0.6.0
CoenraadS.bracket-pair-colorizer@1.0.61
DanielThielking.aws-cloudformation-yaml@0.2.2
donjayamanne.git-extension-pack@0.1.3
donjayamanne.githistory@0.6.9
donjayamanne.python-extension-pack@1.6.0
DotJoshJohnson.xml@2.5.1
eamodio.gitlens@10.2.2
emmanuelbeziat.vscode-great-icons@2.1.52
erd0s.terraform-autocomplete@0.0.8
esbenp.prettier-vscode@5.6.0
felipecaputo.git-project-manager@1.7.1
ffaraone.opensslutils@1.1.1
formulahendry.code-runner@0.11.0
formulahendry.docker-explorer@0.1.7
formulahendry.docker-extension-pack@0.0.1
GrapeCity.gc-excelviewer@3.0.40
hashicorp.terraform@2.2.3
hediet.vscode-drawio@0.7.2
HookyQR.beautify@1.5.0
howardzuo.vscode-git-tags@1.4.4
humao.rest-client@0.24.2
ivangabriele.vscode-git-add-and-commit@2.1.1
jmallien.ReplaceWithNewline@0.0.1
jtavin.ldif@0.2.0
keroc.hex-fmt@1.0.0
lonefy.vscode-JS-CSS-HTML-formatter@0.2.3
magicstack.MagicPython@1.1.0
mark-tucker.aws-cli-configure@0.3.0
mateuszchudyk.hexinspector@1.0.1
mindginative.terraform-snippets@2.1.0
ms-azuretools.vscode-docker@1.5.0
ms-dotnettools.csharp@1.23.2
ms-python.python@2020.8.108011
ms-vscode.powershell@2020.6.0
p1c2u.docker-compose@0.3.5
peakchen90.open-html-in-browser@2.1.3
PlethoraOfHate.aws-actions@1.0.0
qcz.text-power-tools@1.15.0
redhat.java@0.66.0
rogalmic.bash-debug@0.3.9
ryu1kn.partial-diff@1.4.1
shaharkazaz.git-merger@0.4.1
shakram02.bash-beautify@0.1.1
streetsidesoftware.code-spell-checker@1.9.0
tht13.html-preview-vscode@0.2.5
tht13.python@0.2.3
tiibun.vscode-docker-ws@0.4.1
tushortz.python-extended-snippets@0.0.1
Tyriar.sort-lines@1.9.0
vector-of-bool.gitflow@1.2.1
VisualStudioExptTeam.vscodeintellicode@1.2.10
vscjava.vscode-java-debug@0.28.0
vscjava.vscode-java-dependency@0.13.0
vscjava.vscode-java-pack@0.10.0
vscjava.vscode-java-test@0.24.2
vscjava.vscode-maven@0.24.2
vscode-icons-team.vscode-icons@10.2.0
wholroyd.jinja@0.0.8
yzhang.markdown-all-in-one@3.3.0
Zim.vsc-docker@0.34.0
ziyasal.vscode-open-in-github@1.3.6


### PSES version: 2.2.0.0

### PowerShell version:

Name                           Value
----                           -----
PSVersion                      5.1.18362.752
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.752
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Issue Description

I am experiencing a problem with…

Formatting PowerShell code that has “New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent() )” replaces double-colon with a single colon.

– Description of what should be happening –

Formatting PowerShell code that has “New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent() )” retains the double-colon.

– Description of what actually happens –

Steps to Reproduce: In VSCode, create a simple PowerShell script with the following line in it and save the file. $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent() ) Start PowerShell extension. Press SHIFT+ALT+F (format). The double-colon’s in the code are updated to a single-colon as follows. $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]:GetCurrent() ) This formatting change breaks the script and the extra colon needs to be added back manually.

Attached Logs

Follow the instructions in the troubleshooting docs about capturing and sending logs.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
hickmant6commented, Sep 15, 2020

Thanks for reaching Sydney. I have several extensions in VSCode, so one of them may be causing the problem. I’ve not overtly applied any settings for the PowerShell extension that I’m aware of. My settings.json is provided below in case it helps. I deleted gitlens and spell checker content as it was a bit long. But the rest is as it is in my VSCode install. It could very well be that I have mucked it up somehow. All I do know is it is a bit annoying. 😊 Appreciate the help/guidance.

{ “workbench.iconTheme”: “vscode-icons”, “workbench.colorTheme”: “Visual Studio Dark”, “editor.suggestSelection”: “first”, “vsintellicode.modify.editor.suggestSelection”: “automaticallyOverrodeDefaultValue”, “terminal.integrated.shell.windows”: “C:\WINDOWS\System32\cmd.exe”, // “terminal.integrated.shell.windows”: “C:\Windows\System32\OpenSSH\ssh.exe”, // “terminal.integrated.shellArgs.windows”: [“ab0701@localhost”], “python.jediEnabled”: false, “files.exclude”: { “/.classpath": true, "/.project”: true, “/.settings": true, "/.factorypath”: true }, “gitlens.defaultDateStyle”: “absolute”, “gitlens.views.repositories.location”: “scm”, “gitlens.views.fileHistory.location”: “explorer”, “gitlens.views.lineHistory.location”: “explorer”, “gitlens.views.compare.location”: “gitlens”, “gitlens.views.search.location”: “gitlens”, “gitlens.defaultDateFormat”: “MM/DD/YYYY”, “gitlens.defaultDateShortFormat”: “MM/DD/YYYY”, “git.enableSmartCommit”: true, “explorer.confirmDragAndDrop”: false, “explorer.confirmDelete”: false, “git.autofetch”: true, “git.defaultCloneDirectory”: “https://gitlab.pg.com/”, “git.fetchOnPull”: true, “http.proxyStrictSSL”: false, “opensslutils.opensslPath”: “C:\Users\hickman.ta\OneDrive - Procter And Gamble\Data\Program Files\OpenSSL-Win64\bin”, “vsicons.dontShowNewVersionMessage”: true, “[jsonc]”: { “editor.defaultFormatter”: “vscode.json-language-features” }, “terminal.integrated.scrollback”: 5000, “java.home”: “C:\Apps\Java\jdk-12.0.1”, “[json]”: { “editor.defaultFormatter”: “esbenp.prettier-vscode” }, “files.maxMemoryForLargeFilesMB”: 3072, “files.eol”: “\n”, “prettier.endOfLine”: “lf”, “git.confirmSync”: false, “powershell.developer.editorServicesWaitForDebugger”: true, “powershell.powerShellDefaultVersion”: “Windows PowerShell (x86)”, “java.semanticHighlighting.enabled”: true, “files.associations”: { “.dsconfig": “shellscript”, ".tf”: “terraform”, “*.tfvars”: “terraform” }, “python.languageServer”: “Microsoft”, “cSpell.enableFiletypes”: [ “log” ], “workbench.tree.indent”: 15, “[html]”: { “editor.tabSize”: 4, “editor.defaultFormatter”: “lonefy.vscode-JS-CSS-HTML-formatter” }, “editor.tabCompletion”: “on”, “terraform.languageServer”: { “external”: true, “args”: [ “serve” ] }, “csharp.suppressDotnetInstallWarning”: true, “powershell.codeFormatting.useCorrectCasing”: true, “powershell.codeFormatting.ignoreOneLineBlock”: false, “powershell.codeFormatting.newLineAfterCloseBrace”: false, “powershell.codeFormatting.whitespaceBetweenParameters”: true, “[xml]”: { “editor.defaultFormatter”: “DotJoshJohnson.xml” } }

Thanks, Terry Hickman, CISSP, CISM, CIA, CISA Identity and Access Management Security Engineer Information Security, Architecture & Engineering • +1 (513) 983-3281 Å +1 (513) 310-7144 ^ Instant Messagesip:hickman.ta@pg.com


[cid:image001.jpg@01D68B66.6B309780]

From: Sydney Smith notifications@github.com Sent: Tuesday, September 15, 2020 1:41 PM To: PowerShell/PSScriptAnalyzer PSScriptAnalyzer@noreply.github.com Cc: Hickman, Terry hickman.ta@pg.com; Mention mention@noreply.github.com Subject: Re: [PowerShell/PSScriptAnalyzer] Formatting Problem for Security.Principal.WindowsPrincipal( [Security.Principal.WindowsIdentity]::GetCurrent() ) (#1585)

Thanks @hickmant6https://urldefense.com/v3/__https:/github.com/hickmant6__;!!NgSi4SaN6ydtRVQ-!i3NcMxmFs9-NZKJ5YSvj_TzRM87O7Q82cVLEoQ-aHy5mH7-LJ-KKWWHPbRrw3g$ for reporting this issue-- we are having some trouble re-producing this issue, are you using any settings in vscode?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https:/github.com/PowerShell/PSScriptAnalyzer/issues/1585*issuecomment-692869810__;Iw!!NgSi4SaN6ydtRVQ-!i3NcMxmFs9-NZKJ5YSvj_TzRM87O7Q82cVLEoQ-aHy5mH7-LJ-KKWWHU7e5DsQ$, or unsubscribehttps://urldefense.com/v3/__https:/github.com/notifications/unsubscribe-auth/AO6MGEGD5JIF2NW5XXSIFO3SF6RLFANCNFSM4RGQIDJQ__;!!NgSi4SaN6ydtRVQ-!i3NcMxmFs9-NZKJ5YSvj_TzRM87O7Q82cVLEoQ-aHy5mH7-LJ-KKWWEc4KLM4g$.

0reactions
msftbot[bot]commented, Oct 7, 2020

Closing due to inactivity

Read more comments on GitHub >

github_iconTop Results From Across the Web

Formatting Problem for Security.Principal. ...
In VSCode, create a simple PowerShell script with the following line in it and save the file. $currentPrincipal = New-Object Security.Principal.
Read more >
System.Security.Principal.WindowsIdentity.GetCurrent ...
In case you are using windows authentication it contains WindowsPrincipal object, and Identity.Name property contains name in format ...
Read more >
WindowsIdentity.GetCurrent Method (System.Security. ...
GetCurrent (TokenAccessLevels). Returns a WindowsIdentity object that represents the current Windows user, using the specified desired token access level.
Read more >
crc setup/start gets processed with error on Windows 10 ...
I'm trying seutp CodeReady Container on my company laptop with Windows 10 Enterprise OS following the document here:.
Read more >
Windows 11 Upgrade PowerShell Sccript
Greetings I am not an expert on bigfix, However I am trying to run this script via BigFix to run in place upgrade...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found