Typical commands and tasks helpfull using Microsoft systems and applications.
Set-EmailAddressPolicy -EnabledEmailAddressTemplates 'smtp:%m@domain.local','SMTP:%g.%s@domain.com','smtp:%g.%s@domain2.com' -identity 'Default Policy' Update-EmailAddressPolicy -Identity "Default Policy"
domain.com is the default address.
Update the list:
Update-GlobalAddressList -Identity "Default Global Address List"
Configure a dedicated SMTP connector and allow relay on that using:
Get-ReceiveConnector "%NAMEOFCONNECTOR%" | Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" -ExtendedRights "ms-Exch-SMTP-Accept-Any-Recipient"
French version:
Get-ReceiveConnector "%NAMEOFCONNECTOR%" | Add-ADPermission -User "AUTORITE NT\ANONYMOUS LOGON" -ExtendedRights "Ms-Exch-SMTP-Accept-Any-Recipient"
Since you’re not able to see Administrators mailbox in EMC. You can try from EMS running
Get-Mailbox –Identity <AdministratorsAlias> | fl
and see if you have exchange attributes for administrator account such as ProxyAddress, homeMDB, mail, mailNickname etc..
Disable-Mailbox -Identity %ADMINISTRATORALIAS% Clean-MailboxDatabase %MAILBOXDBNAME%
Now try to enable or create mailbox for administrator account you will be able to see the administrator account in Existing users Add list.
Get-MailboxDatabase "%MAILBOXDBNAME%" | Get-MailboxStatistics | Sort totalitemsize -desc | ft displayname, totalitemsize, itemcount
From the Exchange 2010 server:
.\AddReplicaToPFRecursive.ps1 -server "%EXCHANGE2010SERVER%" -TopPublicFolder "\" -ServerToAdd "%EXCHANGE2010SERVER%"
.\MoveAllReplicas.ps1 -Server "%EXCHANGE2003SERVER%" -NewServer "%EXCHANGE2010SERVER%"
Debugging:
To view a list of the replicas in the public folder hierarchy:
Get-PublicFolder -recurse |fl name,replicas
For System Folders:
Get-PublicFolder -recurse \non_ipm_subtree |fl name, replicas
To compare content replicated between the source and destination servers:
Get-PublicFolderStatistics
sqlcmd -S %SERVER%\%INSTANCENAME% -Q "BACKUP DATABASE [%DBNAME%] TO DISK = N'%PATHANDFILENAME%.bak' WITH NOFORMAT, NOINIT, NAME = N'%DBNAME Full Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10"
BACKUP DATABASE %DBNAME% TO DISK = '%PATHANDFILENAME.bak'
use master go Alter database %DBNAME% modify file (name = tempdev, filename = '%FILELOCATION%\%DBNAME%.mdf') go Alter database %DBNAME% modify file (name = templog, filename = '%FILELOCATION%\%DBNAME%.ldf') go
dbcc checkdb ('%DBNAME%') WITH ALL_ERRORMSGS
sp_who;
SQL SERVER 2005:
EXEC Sp_dtabases;
EXEC Sp_helpdb;
SQL SERVER 2000 - still works in SQL Server 2005:
SELECT name FROM sys.databases SELECT name FROM sys.sysdatabases
SQL Unofficial:
EXEC sp_msForEachDB 'PRINT "?"'
exec sp_MSforeachtable @command1="print '?' exec sp_spaceused '?'"
SELECT t.NAME AS TableName, p.rows AS RowCounts, SUM(a.total_pages) * 8 AS TotalSpaceKB, SUM(a.used_pages) * 8 AS UsedSpaceKB, (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB FROM sys.tables t INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id INNER JOIN sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id WHERE t.NAME NOT LIKE 'dt%' AND t.is_ms_shipped = 0 AND i.OBJECT_ID > 255 GROUP BY t.Name, p.Rows ORDER BY UsedSpaceKB
select * from sys.dm_exec_sessions where session_id = @@SPID
sp_helpdb;
kill <spid>;
select name from sys.databases;
RESTORE DATABASE %DBNAME% WITH RECOVERY
USE master; GO ALTER DATABASE OLFWeb SET SINGLE_USER WITH ROLLBACK IMMEDIATE; GO dbcc checkdb ('OLFWeb', REPAIR_ALLOW_DATA_LOSS) WITH ALL_ERRORMSGS ALTER DATABASE OLFWeb SET MULTI_USER; GO
RESTORE FILELISTONLY FROM DISK = 'd:\backupfile.bak'
RESTORE DATABASE %DBNAME% FROM DISK = 'drive:\backupfile.bak' with MOVE '%ORIGINALDBDATANAME%' to 'drive:\dbfile.mdf', MOVE '%ORIGINALDBLOGNAME%' to 'drive:\dblogfile.ldf', replace
Update logical name:
alter database %DATABASE% MODIFY FILE (NAME=%OLDLOGICALFILENAME%",NEWNAME=%NEWLOGICALFILENAME%")
use <dbname> DUMP TRANSACTION <dbname> WITH TRUNCATE_ONLY DBCC SHRINKFILE (2, 10);
On MSSQL 2k8:
USE %DBNAME%; DBCC SHRINKFILE(%DBLOGLOGICALNAME%,1);
To get %DBLOGLOGICALNAME%:
USE %DBNAME%; select name from sys.database_files;
If Full recovery model:
USE %DBNAME%; GO ALTER DATABASE %DBNAME% SET RECOVERY SIMPLE; GO DBCC SHRINKFILE (%DBLOGLOGICALNAME%, 1); ALTER DATABASE %DBNAME% SET RECOVERY FULL; GO
Start in single-user mode:
Stop MSSQL server service and run it in single mode:
sqlservr -c -f
Set the file size:
ALTER DATABASE tempdb MODIFY FILE (NAME = 'tempdev', SIZE = %NEWSIZE%) ALTER DATABASE tempdb MODIFY FILE (NAME = 'templog', SIZE = %NEWSIZE%)
Exit single-user mode and restart the MSSQL service
outlook /rpcdiag
outlook /resetfoldernames
netplwiz
powercfg -h off
kernrate -s 10
Go in command prompt and do the following:
set devmgr_show_nonpresent_devices=1 devmgmt.msc
Select View > Show Hidden Devices
Expand the Network Adapters tree
Right-click the dimmed network adapter, and then select Uninstall
Use the DevCon tool from Microsoft Knowledge Base: 311272 (http://support.microsoft.com/kb/311272/en-us)
msizap.exe G!
msizap.exe is in bin directory of Windows SDK or Platform SDK
To full disable hibernate function:
powercfg.exe /h off
Get-ExecutionPolicy
Set-ExecutionPolicy unrestricted
forfiles /p "%DELPATH%" /s /m *.* /d -%DAYS% /c "cmd /c del @path"
set tmp=%* set tmp=%tmp:/=\% echo %tmp
Test-NetConnection -Port %PORT% -computer %HOSTNAME%
To delete unnecessary SP files after install of SP1:
cd c:\Windows\System32\ compcln.exe
To delete recovery of updates:
compcln.exe
change user /INSTALL
change user /EXECUTE
net stop "Windows update" DISM.exe /Online /Cleanup-image /Restorehealth net start "Windows update"
W32tm /config /manualpeerlist:peers /syncfromflags:manual /reliable:yes /update net stop w32time net start w32time
Check synchro:
w32tm /stripchart /computer:%HOSTNAME%
Service tag dell
wmic bios get serialnumber
Reset attributes attrib -s -h -r “C:\Users\exampleusername”
Display open files:
Openfiles /Query
WSUS: Purge / Delete corrupted or Un-needed patches on WSUS Server WSUSDebugtool /tool:purgeunneededfiles
New-RoutingGroupConnector -Name “2010-2003” -SourceTransportServers “Ex2010Hub1.contoso.com” -TargetTransportServers “Ex2003BH1.contoso.com” -Cost 1 -Bidirectional $false -PublicFolderReferralsEnabled $true New-RoutingGroupConnector -Name “2010-2003” -SourceTransportServers “Ex2003BH1.contoso.com” -TargetTransportServers “Ex2010Hub1.contoso.com” -Cost 1 -Bidirectional $false -PublicFolderReferralsEnabled $true
Get-RoutingGroupConnector| FL
pstools \ psexec
for /f "eol=; tokens=1" %%N in (directories.txt) do cacls.exe "d:\data\users\%%N" /T /E /G DOMAIN\%%N:F >> c:\temp\subinacllog.txt
ROBOCOPY.exe \\SERVER\f$\PATH D:\LOCALPATH /e /zb /copyall /r:1 /w:1 /purge /LOG:c:\temp\robocopy.txt
http://www.sqldbpros.com/2010/11/sql-server-rebuild-indexes-the-fastest-way/
web.config connectionStrings encryption:
cd c:\windows\Microsoft.Net\framework\v4.0.XXXX
Encrypt
aspnet_regiis -pef "connectionStrings" "D:\webistes\leDossierDuSiteContenantLeFichierACrypter"
Decrypt
aspnet_regiis -pdf "connectionStrings" "D:\webistes\leDossierDuSiteContenantLeFichierADérypter"
Display IIS worker processes PID %windir%\system32\inetsrv\appcmd list wp
Dump disk or pen drive:
dd.exe --progress if=\\.\Volume{0b1a0cbe-11da-11c0-ab53-003045c00008} of=pendrive.img bs=4096
Check IOPS and accessed files: resmon.exe