- Details
- Written by: Senka
- Category: Power Shell
- Hits: 1140
Import-Modulet GroupPolicy
Function Get-AllGPO { Get-GPOReport -all -ReportType xml | %{ ([xml]$_).gpo | select name,@{n="SOMName";e={$_.LinksTo | % {$_.SOMName}}},@{n="SOMPath";e={$_.LinksTo | %{$_.SOMPath}}} } } #Get Gpo with name Turn* and display what OU is linked. Get-AllGPO | ? {$_.Name -like "*Turn*"} | ft
- Details
- Written by: Senka
- Category: Power Shell
- Hits: 1048
Get-WmiObject -Namespace "root\cimv2" -Class Win32_Process -ComputerName . | select name,@{name="owner";exp={$_.getowner().user}}
- Details
- Written by: Senka
- Category: Power Shell
- Hits: 1100
import-module activedirectory
function ug {
param([string]$gr)
Get-ADGroupMember "$gr" |? {$_.objectclass -eq "user"} | sort samaccountname | %{$a = $_.samaccountname; echo "$gr;$a;"}
Get-ADGroupMember "$gr" |? {$_.objectclass -eq "group"} | sort samaccountname | %{$a = $_.samaccountname; ug $a}
}
Get-content ./groups.txt | %{
ug "$_"
} > ad_groups.txt
- Details
- Written by: Senka
- Category: Power Shell
- Hits: 1146
function email
{
param([string]$topic = "", [string]$subject = "")
$EmailTo = "
$mailmessage = New-Object system.net.mail.mailmessage
$mailmessage.from = ("
$mailmessage.To.add($emailto)
$mailmessage.Subject = "$topic " + (Get-Date).GetDateTimeFormats("u")
$mailmessage.Body = "<html><head></head><body>" + $subject + "</body></html>"
$mailmessage.IsBodyHTML = $true
$SMTPClient = New-Object Net.Mail.SmtpClient("192.168.11.135", 25)
$SMTPClient.Send($mailmessage)
}
$lwt = Get-Date((Get-ChildItem path-to-file).LastWriteTime) -f "dd.MM.yyyy hh:mm:ss"
email "Отчет по выгрузке" "<html><body>Последняя выгрузка: file - $lwt<br>Последняя выгрузка: $lwt</body></html>"
- Details
- Written by: Senka
- Category: Power Shell
- Hits: 1067
Get-ADGroupMember $group | Move-ADObject -targetpath "OU=IT,OU=Users,DC=tcsbank,DC=ru"