Skip to content

Instantly share code, notes, and snippets.

View chipitsine's full-sized avatar
🏠
Working from home

Ilya Shipitsin chipitsine

🏠
Working from home
View GitHub Profile
select * into #tmpag_availability_groups from master.sys.availability_groups
cls
$sql = ([System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources() | Where { $_.InstanceName -ne 'SQLEXPRESS'})
'number of intances found: {0}' -f $sql.Count
'-----------------------------------------'
$sql
@chipitsine
chipitsine / lost-sites-sh
Last active January 15, 2016 12:56
finds lost sites
#!/bin/sh
if [ ! -d "$1" ]; then
echo "Usage $0 /path/to/sites"
exit 1;
fi
totalsize=0
for site in `ls $1`; do
@chipitsine
chipitsine / move-it.sh
Created December 18, 2015 13:25
перемещаем файлы в архив
#!/bin/bash
if [ ! -f "$1" ]; then
echo "Usage $0 file.txt"
exit 1;
fi
now=$(date +"%m_%d_%Y")
@chipitsine
chipitsine / report.ps1
Last active December 18, 2015 10:23
ежедневный отчет по компьютерам не в домене
#requires -version 4.0
cls
$CurrentDir = [System.IO.Path]::GetDirectoryName($myInvocation.MyCommand.Definition)
$ProgDir = (${env:ProgramFiles(x86)}, ${env:ProgramFiles} -ne $null)[0]
$LogParserExe = (Join-Path $ProgDir '\Log Parser 2.2\LogParser.exe')
$Header = @"
@chipitsine
chipitsine / send.cs
Created December 8, 2015 12:23
перехват ответа smtp-сервера через MailKit
using System;
using MailKit.Net.Smtp;
using MailKit;
using MimeKit;
namespace TestClient
{
class SmtpClient: MailKit.Net.Smtp.SmtpClient
@chipitsine
chipitsine / older.ps1
Created November 13, 2015 11:01
older.ps1
cls
Import-Module ActiveDirectory
$d = (Get-date).AddDays(-30)
Get-ADComputer -Filter { (Enabled -eq $true) -and (OperatingSystem -like "*XP*") -and (PasswordLastSet -ge $d) } -Properties Name, OperatingSystem | ForEach-Object {
Write-Host $_.Name, $_.OperatingSystem
}
@chipitsine
chipitsine / remove2.bat
Last active July 5, 2016 16:25
remove2
DISM.exe /online /cleanup-image /spsuperseded
DISM.exe /online /Cleanup-Image /StartComponentCleanup
@chipitsine
chipitsine / remove unused featires.ps1
Last active October 27, 2015 14:06
remove unused features
cls
$features = dism.exe /online /get-features | Select-String "^Feature Name|^State"
$ParsedFeatures = @()
foreach ($str in $features)
{
if ($str -like "*Feature Name*")
{
$feature = New-Object -TypeName PSObject
$name = $str -replace "Feature Name : ",""
Add-Member -InputObject $feature -MemberType NoteProperty -Name FeatureName -Value $name
@chipitsine
chipitsine / expired passwords.ps1
Created October 8, 2015 12:45
expired passwords
<#
.SYNOPSIS
Create a CSV and HTML Report on Expiring Passwords
.DESCRIPTION
This script will create a report of passwords that are expiring within
the specified time. It will also list users who's passwords have already
expired. The script will create reports in 2 formats, CSV and HTML.
Both are then emailed to the specified user.
Make sure to edit and change the PARAM section to match your environment