Skip to content

Instantly share code, notes, and snippets.

$filter = "(proxyAddresses=SMTP:foo@contoso.com)"
$gcs = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs
$gcs | % {
$searcher = $_.GetDirectorySearcher()
$searcher.Filter = $filter
$results = $searcher.FindAll()
if ($results.Count -gt 0)
{
$results
$searcher = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().FindGlobalCatalog()
$searcher.Filter = "(&(objectClass=user)(msExchMailboxMoveFlags=10))"
$results = $searcher.FindAll()
"Found " + $results.Count.ToString() + " results:"
foreach ($result in $results)
{
$dn = $result.Properties["distinguishedName"][0].ToString()
$dn
$entry = [ADSI]("LDAP://" + $dn)
$entry.Properties["msExchMailboxMoveFlags"].Clear()
$path = '\\server\path\'
$mailboxes = get-mailbox somemailboxfilter
$mailboxes | % {
$folders = Get-MailboxFolderStatistics $_.Alias -archive
$folders = $folders | ? {$_.Name -ne "Top of Information Store"}
$excludeFolders = $folders | % { $_.FolderPath.Substring(1) }
New-MailboxExportRequest -Mailbox $_.Alias -ExcludeFolders $excludeFolders -ExcludeDumpster -IsArchive -FilePath ($path + $_.Alias + '.pst')
}
@ykfq
ykfq / Dump-MailboxSdAsSDDL.ps1
Created August 9, 2016 08:18 — forked from bill-long/Dump-MailboxSdAsSDDL.ps1
Dump msExchMailboxSecurityDescriptor as SDDL format. Useful if you need to inspect the raw ACL.
param($alias)
$searcher = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().FindGlobalCatalog().GetDirectorySearcher()
$searcher.Filter = "(mailnickname=$alias)"
$user = $searcher.FindOne()
$mbxSd = $user.Properties["msExchMailboxSecurityDescriptor"][0]
$sd = New-Object System.Security.AccessControl.RawSecurityDescriptor([byte[]]$mbxSd, 0)
$sd.GetSddlForm("All")
# Save-AllExchangeLogs.ps1
$timeString = (Get-Date).ToString("yyyyMMddHHmm")
$machineName = [Environment]::MachineName
$targetFolder = "$home\desktop\ExchangeLogs-$machineName-$timeString"
md $targetFolder | Out-Null
"Saving $targetFolder\Application.evtx..."
wevtutil epl Application "$targetFolder\Application.evtx"
"Saving $targetFolder\System.evtx..."
@ykfq
ykfq / CheckAllDCsForGuid.ps1
Created August 9, 2016 08:19 — forked from bill-long/CheckAllDCsForGuid.ps1
Check every GC and DC for a specific objectGUID
$guid = "bc87047d-25e8-11d3-9079-00805f31f826"
$gcs = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().GlobalCatalogs
$gcs | % {
$entry = [ADSI]("GC://" + $_.Name + "/<GUID=" + $guid + ">")
if ($entry.Guid -ne $null)
{
$entry
}
else
@ykfq
ykfq / latest-ffmpeg-centos6.sh
Created March 2, 2017 02:45 — forked from mustafaturan/latest-ffmpeg-centos6.sh
Installs latest ffmpeg on Centos 6
# source: https://trac.ffmpeg.org/wiki/CentosCompilationGuide
yum install autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
curl -O http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
@ykfq
ykfq / OpenWithSublimeText3.bat
Created March 18, 2017 09:15 — forked from roundand/OpenWithSublimeText3.bat
Open folders and files with Sublime Text 3 from windows explorer context menu (tested in Windows 7)
@echo off
SET st3Path=C:\Program Files\Sublime Text 3\sublime_text.exe
rem add it for all file types
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3" /t REG_EXPAND_SZ /v "Icon" /d "%st3Path%,0" /f
@reg add "HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text 3\command" /t REG_SZ /v "" /d "%st3Path% \"%%1\"" /f
rem add it for folders
@reg add "HKEY_CLASSES_ROOT\Folder\shell\Open with Sublime Text 3" /t REG_SZ /v "" /d "Open with Sublime Text 3" /f
@ykfq
ykfq / Kubernetes 调度优化--重平衡策略方案整理.md
Created January 29, 2019 06:50
Kubernetes 调度优化--重平衡策略方案整理
<title>Kubernetes 调度优化--重平衡策略方案整理</title>
@ykfq
ykfq / kubectl-get-taints
Last active September 7, 2022 08:19
Get the taints on all nodes in one command.
root@master001:~# kubectl describe node | egrep "Taints"
Taints: gpu=yes:NoSchedule
Taints: <none>
Taints: <none>
Taints: <none>
Taints: node-role.kubernetes.io/master:NoSchedule
Taints: node-role.kubernetes.io/master:NoSchedule
Taints: node-role.kubernetes.io/master:NoSchedule
Taints: <none>
Taints: <none>