The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience. (2) [Avatar] Offline
I have a problem, I have the following script where you run as User common when the same place in the TS, and from the logon user need to check your printer session and share it and give permission to a particular group in the same print.
with all necessary information, but need to change permissions of the Administrative credential


$ result = $ COMP_IMP.Put ()
Setacl.exe-on "NOME_IMP $"-ot prn-ACTN ace-ace "n: $ HOSTNAME $ GROUP_NAME p: full"

I tried various ways but without success.

following the script:

$NOME_IMPRESSORA = "HP Laserjet 1018"
$NOME_GRUPO = "impressao"

$whoami = whoami
$tokens = $whoami.split('\')
$HOSTNAME = $tokens[0]
$USERNAME = $tokens[1]

query session $USERNAME | select-string -pattern $USERNAME > temp.txt
$x = get-content temp.txt
$x = [string]::join(" ", $x)
$words = $x.split(" `t", [stringsplitoptions]::removeemptyentries)
$SESSION_ID = $words[2]




###$pass = cat c:scriptsenha.txt | convertto-securestring -key (1..16)

###$mycred = new-object -typename
System.Management.Automation.PSCredential -argumentlist "marceloimpressora",$pass

$COMP_IMP = Get-WmiObject -class win32_printer | where {$ -match "$NOME_IMPRESSORA"} | where {$ -match"sessão $SESSAO_ID"} | where {$ -match "de $HOST_CLIENT"}

$COMP_IMP.shared = "0"
$result = $COMP_IMP.Put()


setacl.exe -on "$NOME_IMP" -ot prn -actn ace -ace "n:$HOSTNAME$GROUP_NAME;p:full"