Zobrazují se příspěvky se štítkemPowerShell. Zobrazit všechny příspěvky
Zobrazují se příspěvky se štítkemPowerShell. Zobrazit všechny příspěvky

pátek 15. května 2020

Virtual Machine time synchronization in Hyper-V

Get-VMIntegrationService -VMName * -Name "Time Synchronization" | Disable-VMIntegrationService

úterý 30. dubna 2013

Export Message Tracking Results do CSV

get-messagetrackinglog -MessageId "" -resultSize unlimited | select timestamp, sender, {$_.recipients}, messagesubject, clienthostname, serverip, serverhostname, {$_.recipientstatus}, totalbytes, recipientcount, messageinfo | export-csv -Delimiter ";" c:\results.csv

pátek 19. dubna 2013

Nastavení oprávnění ke kalendáří v PS

Set-MailboxFolderPermission uzivatel1:\Kalendář -User uzivatel2 -AccessRights PublishingEditor

pátek 28. srpna 2009

Wake On LAN

function wakeComputer([String]$macAddress)
{
    $mac = [byte[]]($macAddress.split(':') |% {[int]"0x$_"}) 
 
    $UDPclient = new-Object System.Net.Sockets.UdpClient
    $UDPclient.Connect(([System.Net.IPAddress]::Broadcast),4000)
    $packet = [byte[]](,0xFF * 102)
    6..101 |% { $packet[$_] = $mac[($_%6)]}
    $sent = $UDPclient.Send($packet, $packet.Length)
    "$sent bytes sent. The computer $macAddress may be initializing."
}
zdoj: http://blogs.technet.com/migreene/archive/2009/04/01/3221273.aspx

pátek 7. srpna 2009

Šikové CMDLETy

Velikosti mailboxů

Get-MailboxStatistics | Sort-Object TotalItemSize –Descending | ft DisplayName,@{ expression={$_.TotalItemSize.Value.ToMB()}},ItemCount

Seznam počítačů v AD + zobrazení stavu (online/offline)

$strCategory = "computer"
$objDomain = New-Object System.DirectoryServices.DirectoryEntry
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher$objSearcher.SearchRoot = $objDomain$objSearcher.Filter = ("(objectCategory=$strCategory)")
$colProplist = "name"foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}
$colResults = $objSearcher.FindAll()
foreach ($objResult in $colResults){ $objComputer = $objResult.Properties [string]$CN = $objComputer.name
$QueryString = ('Select StatusCode From Win32_PingStatus Where Address = "' + $CN + '"') $ResultsSet = Gwmi -Q "$QueryString" If ($ResultsSet.StatusCode -Eq 0)  {write-host -foreground green "$CN : Online"} else  {write-host -foreground red "$CN : Offline"}}

Exportování seznamu uživatelů s mailboxem

Get-Mailbox | Get-User | select-object identity,department | Export-Csv -Encoding utf8 -noTypeInformation users.csv

Aktivace výjimky SMB ve firewallu

get-netfirewallrule -displaygroup ‘File and Printer Sharing’ | enable-netfirewallrule 

Stav baterie

Get-WmiObject -Class Win32_Battery

Enabled Computers
Get-ADComputer -Filter 'Enabled -eq $true' -Properties * | Sort LastLogonDate | FT Name, OperatingSystem, LastLogonDate -Autosize
(&(&(&(objectCategory=computer)(!userAccountControl:1.2.840.113556.1.4.803:=2))))

Disabled Computers
Get-ADComputer -Filter 'Enabled -eq $false' -Properties * | Sort LastLogonDate | FT Name, OperatingSystem, LastLogonDate -Autosize
(&(&(&(&(objectCategory=computer)(objectClass=user)(useraccountcontrol:1.2.840.113556.1.4.803:=2)))))

Enabled Users
Get-ADUser -Filter 'Enabled -eq $true' -Properties * | Sort LastLogon | FT Name, LastLogon -Autosize
(&(objectCategory=User)(!userAccountControl:1.2.840.113556.1.4.803:=2))

Disabled Users
(&(objectCategory=User)(userAccountControl:1.2.840.113556.1.4.803:=2))

Computer Inventory

http://www.powershellpro.com/why-i-no-longer-hate-writing-documentation/614/