Szukaj na tym blogu

piątek, 29 maja 2015

Exchange 2013 dial tone database recovery

In order to check if the database is in a healthy state we can use the command below, but first we need to be on the same location of the EDB file using either Exchange Management Shell
eseutil /mh

Use the eseutil utility in recovery mode (/r) to bring the database to a clean shutdown
eseutil /r


Use the New-MailboxDatabase cmdlet to create a dial tone database, as shown in this example
New-MailboxDatabase -Name DTDB1 -EdbFilePath D:\DialTone\DTDB1.EDB

Use the Set-Mailbox cmdlet to rehome the user mailboxes hosted on the database being recovered, as shown in this example
Get-Mailbox -Database DB1 | Set-Mailbox -Database DTDB1

Use the Mount-Database cmdlet to mount the database so client computers can access the database and send and receive messages, as shown in this example
Mount-Database -Identity DTDB1

Create a recovery database (RDB) and copy the database and log files containing the data you want to recover into the RDB. Rename edb file name to RDB.edb
New-MailboxDatabase –Recovery –Name  -Server name>  -EDBFilePath ‘X:\folder\RDB.edb’ –LogFolderPath ‘X:\folder\’

Mount the RDB, and then use the Dismount-Database cmdlet to dismount it, as shown in this example.
Mount-Database -Identity RDB1
Dismount-Database -Identity RDB1

After the RDB is dismounted, move the RDB database and log files within the RDB folder to a safe location. This is done in preparation for swapping the recovered database with the dial tone database.
Dismount the dial tone database, as shown in this example. Note that your end users will experience an interruption in service when you dismount this database.
Dismount-Database -Identity DTDB1

Remember about renaming edb file names!

https://technet.microsoft.com/en-us/library/dd979810%28v=exchg.150%29.aspx

wtorek, 26 maja 2015

VB script to send email from exchange

Dim objNTInfo
Set objNTInfo = CreateObject("WinNTSystemInfo")
GetComputerName = objNTInfo.ComputerName

mTo = WScript.Arguments.Item(0)
mFrom = "SCCM-OSD@domainB.com"
mSubject = "Need to change domainA.com email address to domainB.com in distribution groups"

mbody = "check content of c:\temp\listalista.txt on exchange server then use C:\temp\replaceAPdistList.ps1 "

sendmail mTo, mSubject, mBody, mFrom


Function SendMail(strTo,strSubject,strBody,strFrom)
Dim m_EmailObj, m_EmailConfig
Set m_EmailObj = CreateObject("CDO.Message")
m_EmailObj.From = strFrom
m_EmailObj.To = strTo
m_EmailObj.Subject = strSubject
'm_EmailObj.TextBody = strBody


m_EmailObj.HTMLBody = strBody
Set m_EmailConfig = m_EmailObj.Configuration
m_EmailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "ExchangeServerName"
m_EmailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
m_EmailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
m_EmailConfig.Fields.Update
m_EmailObj.Send
Set m_EmailObj = nothing
Set m_EmailConfig = nothing
End Function

Exchange - Find specific mail addresses in all distribution group

Get-DistributionGroup -Identity *  -ResultSize Unlimited | Select-Object name | set-content C:\temp\allDistNames.txt
$names = gc C:\temp\allDistNames.txt
#remove no needed brackets and other signs
$cont = foreach ($n in $names) {
$n.remove(0,7) -replace ".$"
}
$cont | set-content C:\temp\allDistNames.txt

$names = gc C:\temp\allDistNames.txt
foreach ($n in $names) {
Get-DistributionGroupMember -Identity $n -ResultSize Unlimited | Select-Object PrimarySmtpAddress | set-content C:\temp\temp.txt
$mails = gc C:\temp\temp.txt

#remove no needed brackets and other signs
$cont = foreach ($m in $mails) {
$m.remove(0,21) -replace ".$"
}

foreach ($c in  $cont) {
#get only not empty mails\lines
if ($c.Length -gt 3) {
#search last 14 characters and compary them
if ($c.substring($c.Length-15) -eq "applypoland.com") {
#put the names of distribution list in text file
$n | out-file c:\temp\listalista.txt -append
}
}
}
}


Below script is using for replace emails ended with applypoland.com to ended with applysorco.no

Get-DistributionGroupMember -Identity testbb | Select-Object PrimarySmtpAddress | set-content C:\temp\testbb1.txt
$mails = gc C:\temp\testbb1.txt
$cont = foreach ($m in $mails) {
$m.remove(0,21) -replace ".$"
}
foreach ($c in  $cont) {
if ($c.substring($c.Length-15) -eq "applypoland.com") {
$c | out-file c:\temp\ap.txt -append
$c = $c -replace 'applypoland.com','applysorco.no' | out-file c:\temp\sorco.txt -append
}
}
$usun = gc c:\temp\sorco.txt
foreach ($u in  $usun) {
add-DistributionGroupMember -Identity testbb -member $u
}
$dodaj = gc c:\temp\ap.txt
foreach ($d in  $dodaj) {
remove-DistributionGroupMember -Identity testbb -member $d -Confirm:$False
}

poniedziałek, 18 maja 2015

Exchange 2013 remote powershell

In PowerShell:
$session = New-PSSession -ConfigurationName microsoft.exchange -ConnectionUri http://FQDN/
powershell
Import-PSSession $session

If You need this every time You open PowerShell:
PS C:\> $profile
C:\Users\xxx\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
then change this ps1 file adding above 2 lines

piątek, 15 maja 2015

SCCM configuration baseline samples

Configuration item which helps to find computers with Windows Media Player installed:
Setting type: Script

$ff = dism /online /get-featureinfo /featurename:WindowsMediaPlayer | findstr State
If ($ff -eq "State : Enabled") {
    $Compliance = "Compliant"

Else { 
    $Compliance = "NonCompliant"
}
Return $Compliance

Compliance rule:

------------------------------------------------------------------------------------

Configuration item which helps to find computers with PowerShell 3.0 installed
Setting type: WQL query

Compliance rule:

------------------------------------------------------------------------------------

Configuration item which helps to find computers with missing WSUS configuration
Setting type: Registry value
and

Compliance rule:
and

SCCM best practices for collections

User collections should be based on AD user groups. Common scenario is to name group for the name of application which users in specific group use, e.g. APP - Autocad. Then the collection name should be the same as AD group. Thanks for user collections You can deploy software on any computer on which user is or will be working on

Device collections - good practice is to create folders under each You can get collections designed for specific purpose
IsInstalled contain collection based on Configuration Baseline, e.g. PowerShell 3.0_All Windows 7 Computers Active_Compliant
Thanks for this approach You can schedule deployment of specific software to such collections, e.g. App-V 5.0 client needs PowerShell 3.0 as prerequisite so we scheduled App-V deployment for PowerShell 3.0_All Windows 7 Computers Active_Compliant collection. The easiest way to create such collections based on Configuration Baseline is shown below

Another approach to create collection for specific software installed is based on query, below sample for Citrix Reciver 3.4 IsInstalled 

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceId = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName = "Citrix Receiver (Enterprise)" and SMS_G_System_ADD_REMOVE_PROGRAMS.Version = "13.4.0.25"

or for AutoCAD

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS_64 on SMS_G_System_ADD_REMOVE_PROGRAMS_64.ResourceId = SMS_R_System.ResourceId where LOWER(SMS_G_System_ADD_REMOVE_PROGRAMS_64.DisplayName) like "AutoCAD%" and SMS_R_System.Obsolete = 0

IsNotInstalled can be based on similar like above examples or another approach is to use rules Include Collections and Exclude Collections

UnwantedSoftware can store collections with software which should be automatically uninstalled when detected, e.g. specific version of Java or torrent software.

You create a package with data source files and associate with it some programs like Uninstall Java Auto Updater which contains:
msiexec /x {4A03706F-666A-4037-7777-5F2748764D10} /qn /norestart

Collection for computers with Java Auto Updater can be based on query like below:

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_ADD_REMOVE_PROGRAMS on SMS_G_System_ADD_REMOVE_PROGRAMS.ResourceId = SMS_R_System.ResourceId where SMS_G_System_ADD_REMOVE_PROGRAMS.DisplayName = "Java Auto Updater"



Collection for computers with specific network card:
select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_NETWORK_ADAPTER on SMS_G_System_NETWORK_ADAPTER.ResourceId = SMS_R_System.ResourceId where SMS_G_System_NETWORK_ADAPTER.Description = "Intel(R) 82567LM-3 Gigabit Network Connection"


Maintenance - can store another collections which are build on already created (e.g. All Windows 7) in another place but have setup maintenance window

Power Plan - similar like Maintenance folder but have a power management configured, like wakeup time

SCCM 2012 application redistribute content to DP

Let's consider following scenario: there is an application (not package) which is installed using script install.bat You provide some changes to script and need to update the application to DP. If You go into Properties of Application and go to tab Content Locations
there You can click Redistribute button. But in case of such change in Application it will not cause that new version of Application will be created on DP and new version on install.bat will not be distributed.

You can check it using Content Library Explorer from Configuration Manager Toolkit 2012 R2. Using this tool You can copy content of any application or package from DP to selected folder.

What You need to do is to select Application in SCCM console, then go to Deployment Types tab (on the bottom) right click and choose Update content

środa, 13 maja 2015

SCCM Net Framework 4.5.1 installation problems

I need to install Net Framework 4.5.1 during OS deployment task sequence. I want to have it in SCCM as application not the package. Thanks for this it is easy to use it later as dependency for another applications.

To successfully install it during OS deployment task sequence (no user logged on) You need to mark check box "Run installation and uninstall program as 32-bit process on 64-bit clients" in program properties. Installation program should looks like:
NDP451-KB2858728-x86-x64-AllOS-ENU.exe /q /norestart /ChainingPackage ADMINDEPLOYMENT /log c:\windows\temp\dotnet451.log

Detection method is based on registry (Key: SOFTWARE\Classes\Installer\Products\BE4EBED704B66673BB53C5BB3C58AD73)

I tested it using OS deployment task sequence which contains a lot of different software installation. To speed it up I disabled some steps in task sequence for test purposes. Then Net Framework was installed ok. I enabled all previously disabled steps and test OS deployment task sequence once again. There was an error with Net Framework installation 13EC - looks like there was not enough disk space (tested in on VM with small disk)

wtorek, 12 maja 2015

SCCM application installation failed - not enough cache size

User reports that he cannot install specific application from application catalog. Check the cas.log and execmgr.log on client wokstation. In cas.log there was info about not enough space in cache. You can change it easily using SCCM console (ConfigMgr 2012 Right Click Tools http://myitforum.com/myitforumwp/2012/05/07/config-manager-2012-right-click-tools/), right click on specific computer, then Client Tools -> Change cache size. Restart PC to speed up cache size changes

środa, 6 maja 2015

SCCM collection for active computers

Below is a sample query to create such collection:

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_CH_ClientSummary on SMS_G_System_CH_ClientSummary.ResourceId = SMS_R_System.ResourceId where SMS_G_System_CH_ClientSummary.ClientActiveStatus = 1

SCCM configuration baseline - unknown state "client check passed\acive"

CIDownloader.log - details about configuration item definition downloads, You need to search by GUID. You can find this GUID from SCCM console, under configuration baselines - show column: CI Unique ID

DCMAgent.log is the log located on client in which You can find when specific baseline was run last time, below example line from log:
DCMAgentJob({698E2389-8394-491E-91DA-FB9C7222F173}): CDCMAgentJob::SetupJob - Add assignment Java Installation IsValid_All Windows 7 Computers Active({554557FF-3A41-49FB-BAA9-672B5A3510FF})

Java Installation - is the name of baseline

DCMAgent.log - next log to check on client

Status:
'Client check passed/Inactive' means these are machines which were previously responding to SCCM but are currently switched off, unplugged, offline etc.

'Client check passed/Active' 
"Unknown" is not a good name for this, for each system, a deployment's status starts as "Unknown", moves to "In-Progress", and finishes as "Compliant". 
Most like computers need to be restarted, pending restart after windows updates installation etc.

wtorek, 5 maja 2015

Visio 2013 app-v 5.0 package

Activation done by KMS – there is a need to have at least 5 computers with Office 2013 to start KMS activation!!! Visio 2013 packaged by using Office Deployment Tool. First step is to change configuration.xml file, for Visio 2013 it should looks like below:
<Configuration>
  <Add SourcePath="c:\Visio2013volume" OfficeClientEdition="32" >
    <Product ID="VisioStdVolume">
      <Language ID="en-us" />
    </Product>
  </Add> 
</Configuration>

Then You run setup.exe /download configuration.xml
Next step is to create app-v package using Office Deployment Tool 
setup.exe /packager package.xml c:\visio2013appv
Below is a sample package.xml

<Configuration>
  <Add SourcePath="c:\Visio2013volume" OfficeClientEdition="32" >
    <Product ID="VisioStdVolume">
      <Language ID="en-us" />
    </Product>
  </Add> 
  <Updates Enabled="TRUE"/>
  <Display Level="Full" AcceptEULA="TRUE" />
  <Logging Level="Standard" Path="c:\Visio2013volume\logs" />
  <Property Name="AUTOACTIVATE" Value="1" />
  <Property Name="FORCEAPPSHUTDOWN" Value="TRUE" />
</Configuration>
Important notes: Removal package If You unpublished application it still persist some data on disk %ProgramData%\App-V\{PkgGUID}\{newVerGUID}. To remove all data use Remove-AppVClientPackge



Deploying App-V 5.0 client using SCCM

App-v 5 client on workstations: PoweShell 3.0 is a prerequisite.
To have both 4.6 and 5.0 client version in place on workstation app-v 4.6 client must be updated to SP3
1. Install PowerShell 3.0 (separate package and separate deployment)
program properties:
wusa PowerShell3.msu /passive /quiet /norestart
You need to wait for a service window because powershell will be fully installed after computer restart
deployment properties:
allow for software installation outside maintenance window
configuration baseline and collection:
Based on PowerShell 3.0 configuration baseline there is a collection created under Device Collections \ Application \ IsInstalled \ PowerShell 3.0

Configuration Item is configured as below:

Compliance rule looks like below:

2. Install app-v 5 sp3 (separate package and separate deployment)
deployment properties:
Deployment is performed based on PowerShell 3.0 collection

By default app-v 5 client has no GUI – You need to download it and install separately. It can be installed as virtual application or as normal software.

The App-v 5 SP3 client is installed using install.bat
appv_client_setup.exe /CEIPOPTIN=0 /MUOPTIN=1 /ACCEPTEULA=1 /S1PUBLISHINGSERVERNAME=srvname /S1PUBLISHINGSERVERURL=http://srvname.domain.com:8001 /S1USERREFRESHONLOGON=1 /S1USERREFRESHENABLED=1 /S1GLOBALREFRESHONLOGON=1 /S1GLOBALREFRESHENABLED=1  /ENABLEPACKAGESCRIPTS=1 /MIGRATIONMODE=1 /log c:\windows\temp\appv5.log /q


Lessons learnt:
PowerShell 3.0 deployment errors:
1. error code 2145124330 - another updates were installed, there is a need to restart computer
2. error code 1151 - broken windows update service (to many updates injected offline by DISM) - system re installation needed
3. Program failed (run time exceeded) - if deployment is setup with Rerun if failed previous attempt option and there are more than one schedule assignment it should automatically rerun


poniedziałek, 4 maja 2015

KMS for Office 2013

To check KMS status for Office 2013, type on KMS server:
slmgr /dli 2E28138A-847F-42BC-9752-61B03FFF33CD

Currect count must at least 5

To manually activate Office 2013 (it is faster) type on client:
C:\Program Files (x86)\Microsoft Office\Office15\cscript ospp.vbs /act