Wiki

Microsoft OS and Applications

Typical commands and tasks helpfull using Microsoft systems and applications.

Exchange 2007

Default Email Address Policy

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.

Global Address List

Update the list:

Update-GlobalAddressList -Identity "Default Global Address List"

SMTP relay

Configure a dedicated SMTP connector and allow relay on that using:

Get-ReceiveConnector "NAME OF CONNECTOR" | Add-ADPermission -User "NT AUTHORITY\ANONYMOUS LOGON" -ExtendedRights "ms-Exch-SMTP-Accept-Any-Recipient"

Exchange 2010

Move Exchange 2003 Public Folders to Exchange 2010

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

MSSQL

Backup Database With Script

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 With SQL Command

BACKUP DATABASE %DBNAME% TO DISK = '%PATHANDFILENAME.bak'

Change DB File Location

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

CleanCheck

dbcc checkdb ('%DBNAME%') WITH ALL_ERRORMSGS

Get all current connections

sp_who;

Get all Databases Informations

Sp_helpdb;

Get all Tables Size

exec sp_MSforeachtable @command1="print '?' exec sp_spaceused '?'"

Get variables

select * from sys.dm_exec_sessions where session_id = @@SPID

Informations about databases

sp_helpdb;

Kill a current connection

kill <spid>;

List databases

select name from sys.databases;

Repair Database

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 database

RESTORE FILELISTONLY FROM DISK = 'd:\backupfile.bak'
RESTORE DATABASE %DBNAME% FROM DISK = 'drive:\backupfile.bak' 
with MOVE '%ORIGINALDBNAME%' to 'drive:\dbfile.mdf', 
MOVE 'dblogname_log' to 'drive:\dblogfile.ldf', replace

Trunkate logs mssql database

use <dbname> DUMP TRANSACTION <dbname> WITH TRUNCATE_ONLY DBCC SHRINKFILE (2, 10);

Trunkate tempdb database files

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

Diag Connection To Exchange

outlook /rpcdiag

Reset Default Folders Language

outlook /resetfoldernames

Windows

General

Disable Hibernation

powercfg -h off

Interrupts Statistics

kernrate -s 10

Hardware Management

Delete Disconnected Hardware

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

Manage Hardware From Prompt

Use the DevCon tool from Microsoft Knowledge Base: 311272 (http://support.microsoft.com/kb/311272/en-us)

Power management

To full disable hibernate function:

powercfg.exe /h off

Scripting

Remplace Slash by Backslash

set tmp=%*
set tmp=%tmp:/=\%
echo %tmp

ServicePack cleanup manager

To delete unnecessary SP files after install of SP1:

cd c:\Windows\System32\
compcln.exe

To delete recovery of updates:

compcln.exe

Terminal Server Install/Execute mode

change user /INSTALL
change user /EXECUTE

ToDo

W32tm /config /manualpeerlist:peers /syncfromflags:manual /reliable:yes /update 
net stop w32time
net start w32time

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

wiki/microsoft-os-and-applications.txt · Last modified: 2012/04/16 13:42 by ach
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki