Home
- Details
- Written by: Senka
- Category: C#
- Hits: 1346
private static string POST(string Url, string Data)
{
System.Net.WebRequest req = System.Net.WebRequest.Create(Url);
req.Method = "POST";
req.Timeout = 60000;
req.ContentType = "application/x-www-form-urlencoded";
UTF8Encoding utf8 = new UTF8Encoding();
byte[] sentData = utf8.GetBytes(Data);
//byte[] sentData = Encoding.GetEncoding(1251).GetBytes(Data);
//sentData = Encoding.Convert(1251, "utf-8", sentData);
req.ContentLength = sentData.Length;
System.IO.Stream sendStream = req.GetRequestStream();
sendStream.Write(sentData, 0, sentData.Length);
sendStream.Close();
System.Net.WebResponse res = req.GetResponse();
System.IO.Stream ReceiveStream = res.GetResponseStream();
System.IO.StreamReader sr = new System.IO.StreamReader(ReceiveStream, Encoding.UTF8);
//Кодировка указывается в зависимости от кодировки ответа сервера
Char[] read = new Char[256];
int count = sr.Read(read, 0, 256);
string Out = String.Empty;
while (count > 0)
{
String str = new String(read, 0, count);
Out += str;
count = sr.Read(read, 0, 256);
}
return Out;
}
- Details
- Written by: Senka
- Category: Power Shell
- Hits: 1222
Get-ADUser -Filter * -property * | Select SamAccountName,Name,CanonicalName,EmailAddress,PasswordLastSet, WhenCreated,PasswordExpired,PasswordNeverExpires,ProfilePath,Department, Title,Manager,@{Name="Disabled"; Exp={$_.useraccountcontrol -band 2}}|?{$_.Disabled -eq 0 -and $_.PasswordNeverExpires -eq 'True'}| export-csv user_password_never_expire.csv -encoding Default
- Details
- Written by: Senka
- Category: Power Shell
- Hits: 1360
$computers = Get-ADComputer -filter {OperatingSystem -like '*server*'} -Properties * | Select Name,OperatingSystem,OperatingSystemVersion,OperatingSystemServicePack, PrimaryGroup,IPv4Address,IPv6Address,CanonicalName,WhenCreated, LastlogonTimestamp,PasswordLastSet,@{Name="Disabled"; Exp={$_.useraccountcontrol -band 2}}| ?{$_.Disabled -eq 0}
- Details
- Written by: Senka
- Category: Power Shell
- Hits: 1196
$date = (Get-Date).AddDays(-90)
Get-ADUser -Filter {lastlogontimestamp -gt $date} -property * | Select SamAccountName,Name, EmailAddress,CanonicalName,Manager,lastlogontimestamp,@{Name="Disabled"; Exp={$_.useraccountcontrol -band 2}}| ?{$_.Disabled -eq 0} | export-csv active_users.csv -Delimiter ";" -NoTypeInformation -Encoding Default
- Details
- Written by: Senka
- Category: Exchange Server
- Hits: 1244
$mailboxs = Get-Mailbox -server Mail
'Name;PrimarySmtpAddress;Received;Sent' > mbald.csv
foreach ($mailbox in $mailboxs)
{
$received = Get-TransportServer | Get-MessageTrackingLog -ResultSize unlimited -Start (Get-Date).AddDays(-7) -End (Get-Date) -EventId "RECEIVE" -Recipients $mailbox.PrimarySmtpAddress | Measure-Object
$sent = Get-TransportServer | Get-MessageTrackingLog -ResultSize unlimited -Start (Get-Date).AddDays(-1) -End (Get-Date) -EventId "RECEIVE" -Sender $mailbox.PrimarySmtpAddress | Measure-Object
'"' + $mailbox.name + '";"' + $mailbox.PrimarySmtpAddress + '";"'+ $received.count + '";"'+ $sent.count + '"' >> mbald.csv
}