Answer the question
In order to leave comments, you need to log in
Why is the output of the powersheel script not working correctly?
Good afternoon.
Tell me what I'm doing wrong? There is a small script for granting access to network folders, it is divided into several points, one of them does not work correctly if you use this construction:
Write-Host ″Menu″ -BackgroundColor White -ForegroundColor Red
Write-Host ″1. Посмотреть права на папку″ -ForegroundColor Green
Write-Host ″2. Exit″ -ForegroundColor Green
while($true)
{
$choice = Read-Host ″Выберите пункт меню″
Switch($choice){
1 {
$path = "C:\Temp"
(get-acl $path ).access | select IdentityReference, IsInherited, FileSystemRights
}
2 {Write-Host ″Exit″; return}
default {Write-Host ″Wrong choice, try again.″ -ForegroundColor Red}
}
}
″Menu″
″1. View folder permissions″
″2. Exit″
″Select Menu Item″: 1
″Select Menu Item″: 1
IdentityReference IsInherited FileSystemRights
----------------- ----------- --- -------------
BUILTIN\Administrators True FullControl
NT AUTHORITY\SYSTEM True FullControl
BUILTIN\Users True ReadAndExecute, Synchronize
NT AUTHORITY\Authenticated True Modify, Synchronize
NT AUTHORITY\Authenticated True -536805376
BUILTIN\ True FullControl Administrators
NT AUTHORITY\SYSTEM True FullControl
BUILTIN\Users True ReadAndExecute, Synchronize
NT AUTHORITY\Authenticated True Modify, Synchronize
NT AUTHORITY\Authenticated True -536805376
″Select Menu Item″: 1
BUILTIN\Administrators True FullControl
NT AUTHORITY\SYSTEM True FullControl
BUILTIN\ Users True ReadAndExecute, Synchronize
NT AUTHORITY\Tested True Modify, Synchronize
NT AUTHORITY\Tested True -536805376
″Select Menu Item″:
Answer the question
In order to leave comments, you need to log in
This is due to the peculiarities of how Output works.
The easiest way to decide in your case is to add | Out-Host after select
if you are doing interactive, then always use xxx-Host cmdlets,
mix default output with output to host - just get glitches like this
. And, yes, code formatting is creepy. Don't skimp on translations
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question