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.

marcelo@cdznet.com.br (2) [Avatar] Offline
#1
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

lines

$ result = $ COMP_IMP.Put ()
and
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"
$COMP_IMPRESSORA = "HPLASER"
$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]

$HOST_CLIENT = cmd /c echo %CLIENTNAME%

$IMP_SESSION = $NOME_IMPRESSORA

$NOME_IMP = "$IMP_SESSION (de $HOST_CLIENT) na sessão $SESSION_ID"


###$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 {$_.name -match "$NOME_IMPRESSORA"} | where {$_.name -match"sessão $SESSAO_ID"} | where {$_.name -match "de $HOST_CLIENT"}

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


$GROUP_NAME = $NOME_GRUPO

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