Skriptgesteuerte Drucker-Installation
26. Juni 2018
Aus Sicherheitsgründen sollten die Systembetreuer immer genau im Bilde sein, welche IT-Ressourcen von welchen Mitarbeitern in Anspruch genommen wurden. Beispielsweise können die Systembetreuer in Erfahrung bringen wollen, wann welcher User auf einen bestimmten Printer zugegriffen hat. Für derartige Aufgabenstellungen eignet sich die Windows Powershell, denn mit den passenden Skripten und Cmdlets lässt sich dies einfach und schnell realisieren:
1
function
Get-PrinterServerUsers {
4
List all
users
that have printed from specified printerservers the last xxx days.
6
The
function
creates a list of all
users
that have used specified printerservers.
7
To be able to collect the events you need to log spooler information events.
8
.PARAMETER Computername
9
A single computer name or an array of computer names. You may also provide IP addresses.
11
The number of days from todays
date
you whant to list.
13
Get-PrinterServerUsers -computername srv-print01, srv-print02 -days 90
17
This will collect all the
users
that have prited from a printer through the servers
18
srv-print01 and srv-print02 the last 90 days, and
export
them to a textfile with the
19
servername located at c:\temp.
23
Function by Viktor Lindström
28
[parameter(mandatory=$
true
)]
41
if
( -Not (Test-Path $tempdir))
42
{ New-Item -Path $tempdir -ItemType Directory
46
foreach ($server
in
$computername)
47
{Write-Host collecting
users
from $server
48
$Duration = Measure-Command {
49
$
users
= get-eventlog -ComputerName $server -LogName system -After $
date
.AddDays(-$days) | where {$_.eventID -
eq
10} |
select
UserName
50
$unique = $
users
| Sort-Object username | Get-Unique -AsString
51
$unique | Export-Csv c:\temp\$server.txt -NoTypeInformation }
52
Write-host
"$($Server) done in $($Duration.Minutes):$($Duration.Seconds) mm:ss"
Florian Huttenloher