Windows/powershell: Unterschied zwischen den Versionen

Aus SchnallIchNet
Wechseln zu: Navigation, Suche
Zeile 34: Zeile 34:
 
  Get-ADUser -Filter * -Properties DisplayName, EmailAddress, Title -SearchBase 'OU=HPI,DC=fleet,DC=int' \
 
  Get-ADUser -Filter * -Properties DisplayName, EmailAddress, Title -SearchBase 'OU=HPI,DC=fleet,DC=int' \
 
  -Server 'Fleet.int' | Export-CSV c:\temp\FleetInt.csv
 
  -Server 'Fleet.int' | Export-CSV c:\temp\FleetInt.csv
 +
 +
 +
== set thumbnail-image ==
 +
 +
from an exchange server
 +
 +
Import-RecipientDataProperty -Identity dSchlenzig -Picture -FileData \
 +
([Byte[]]$(Get-Content -path ".\thumb-DOMARI.jpg"  -Encoding Byte -ReadCount 0))
 +
 +
 +
from an AD
 +
 +
$photo = [byte[]](Get-Content path of pic -Encoding byte)
 +
Set-ADUser username -Replace @{thumbnailPhoto=$photo}

Version vom 29. Dezember 2015, 17:02 Uhr

Snippets for powershell
Note that Exchange-related powershell commands should be listed here

get loadable modules

Get-Module -ListAvailable


Get Service names

Get-Service | Where-Object {$_.displayName.StartsWith("watch")} | Select name

get list of services that start with watch* (case sensitive)

Get-Service | Where-Object {$_.displayName.StartsWith("watch")} | Start-Service
Get-Service | Where-Object {$_.displayName.StartsWith("watch")} | Stop-Service
Get-Service | Where-Object {$_.displayName.StartsWith("watch")} | Restart-Service


Get Group Memberships of AD-Object

Get-ADPrincipalGroupMembership -identity <USER>


Filter Users

Get-ADUser -Filter * -Properties DisplayName, EmailAddress, Title -SearchBase 'OU=Fleetservices User,DC=fleetservices,DC=intra' \
-Server 'Fleetservices.intra'


or export result to CSV-File

Get-ADUser -Filter * -Properties DisplayName, EmailAddress, Title -SearchBase 'OU=HPI,DC=fleet,DC=int' \
-Server 'Fleet.int' | Export-CSV c:\temp\FleetInt.csv


set thumbnail-image

from an exchange server

Import-RecipientDataProperty -Identity dSchlenzig -Picture -FileData \
([Byte[]]$(Get-Content -path ".\thumb-DOMARI.jpg"  -Encoding Byte -ReadCount 0))


from an AD

$photo = [byte[]](Get-Content path of pic -Encoding byte)
Set-ADUser username -Replace @{thumbnailPhoto=$photo}