Wednesday 15 June 2016

Configuring new DSC Pull server - error Nº1 - Error executing Start-DSCConfiguration

Hi all!

I'm starting another series of posts about my experiences with PowerShell DSC!!

As it can not be otherwise, I'm going to start with an error...so here we go!


the error:

You just configured a your new DSC Pull server, using xWebService resource, and created your first MOF file that you are going to use to start DSC Pull server configuration, and run:

Start-DscConfiguration -Path c:\\PullServer -Wait -Verbose

After some information messages...
The expression after '&' in a pipeline element produced an object that was not valid. It must result in a command name, a script block, or a CommandInfo object.
    + CategoryInfo          : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : BadExpression
    + PSComputerName        :

the solution:

This error appears because of known issue #143, reported in GitHub.

Although the version is in dev(at the moment I write this post), you can go here, download the full zip and copy files:


xPSDesiredStateConfiguration-dev.zip\xPSDesiredStateConfiguration-dev\DSCResources\MSFT_xDSCWebService\...
             MSFT_xDSCWebService.psm1
             PSWSIISEndpoint.psm1 

Then you only need to overwrite the old ones (remember to backup) at:
C:\Program Files\WindowsPowerShell\Modules\xPSDesiredStateConfiguration\3.10.0.0\DSCResources\MSFT_xDSCWebService
That's all!

Wednesday 18 May 2016

Error enabling Operations Manager Audit Collection Service with SCOM 2016 TP4

Hi all,

If you want to install Operations Manager Audit Collection Service and the Audit collection services Collector Setup Wizard finishes with the following error:
start adtserver service: failure 0x00002098
...should it mean that you have some problems with the SPNs(Service Principal Name). If you check the Event Viewer,  you will find the following error registered:
EventID: 7023
Source: Service Control Manager
Message: The Operations Manager Audit Collection Service service terminated with the following error: Insufficient access rights to perform the operation.
Then the solution it's easy, you need to register the required SPN in order the service can start correctly:

Management Server:

  • AdtServer/FQDN DOMAIN\account
  • AdtServer/NetBios DOMAIN\account
  • MSOMHSvc/FQDN DOMAIN\account
  • MSOMHSvc/NetBios DOMAIN\account
Database Server:
  • MSSQLSvc/FQDN:1433 DOMAIN\account
  • MSSQLSvc/FQDN DOMAIN\account
  • MSSQLSvc/NetBios DOMAIN\account
Ok...let's go to see a real case...

Suppose you has a management server named "ScomServer", database server "RandomDBServer" and a domain named "TheXdom.com". Then the "Operations Manager Audit Collection Service" is running under "Network Service" account and the "SQL Server" service running under "TheXdom\sqlEngineAcc". Then you need to run in a elevated command prompt:

  1. setspn -S AdtServer/ScomServer.TheXdom.com TheXdom\ScomServer$
  2. setspn -S AdtServer/ScomServer TheXdom\ScomServer$
  3. setspn -S MSOMHSvc/ScomServer.TheXdom.com TheXdom\ScomServer$
  4. setspn -S MSOMHSvc/ScomServer TheXdom\ScomServer$
  5. setspn -S MSSQLSvc/RandomDBServer.TheXdom.com TheXdom\sqlEngineAcc
  6. setspn -S MSSQLSvc/RandomDBServer TheXdom\sqlEngineAcc
Don't worry if your environment still have one of these SPN, the -S parameter checks it for you!


If these steps cannot solve your problem, perhaps you need to check this Microsoft KB

Hope it helps!

Saturday 21 March 2015

explorer.exe and Print Management suddenly stops in a Citrix environment

Hi all!

Some weeks ago I hit my head with a easy but annoying error: When a user opens a explorer.exe or Print Management published application in a Citrix environment, the application suddenly stops/disappear with no error message. After a time troubleshooting, it seems to appear a hidden error message: Server execution failed


In spite of we have two different errors: explorer.exe and Print Management, the error is the same because Print Management application runs explorer.exe with a parameter.

Environment:

Citrix 7.5 running Windows Server 2008 R2.

The problem:

The error appears because Windows Explorer looks for "Personal" folder specified in the registry hive:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\

If the folder does not exist, fails.


Resolution:

The problem was detected and solved by Microsoft with the KB2444677

If you cannot apply the KB article(restart needed, or others...) you can do two actions:
  1. Change the folder path for an existing
  2. Create the specified folder

Hope it helps!


Wednesday 7 January 2015

[FastToUse] - Find Exchange 2010 AntiSpam filtered e-mails.

What?
When you need to check if an email is filtered by Exchange 2010 AntiSpam filters, it use to be a tedious task. This will not be a problem if you use a simple script to find the filtered e-mail by domain o full-e-mail address.

Fast Instructions:
  • Copy & Paste the following PowerShell code into a FindSPAMemails.ps1 file.
  • Save the file in a accessible site in order to use it when necessary.
PowerShell:

add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010; . 'C:\Program Files\Microsoft\Exchange Server\V14\bin\Exchange.ps1'
cls
while (1 -eq 1){
                $domini = Read-Host 'Enter the domain name or mail address(i.e: domain.com or mail@domain.com)'
                Write-Host "You entered: " $domini " , starting search..."
                Get-AgentLog | select P1FromAddress,P2FromAddresses,Agent,Action,Reason,ReasonData,Diagnostics,Timestamp | where {$_.Action -ne "AcceptMessage"} | where {$_.P1FromAddress -like "*$domini*"}
                $opcio = Read-Host 'Continue searching? (Y/N), default option -> N'
                while ($ok -ne "ok"){
                               if(($opcio -eq "N") -or ($opcio -eq "n") -or ($opcio -eq "")) {exit}
                               elseif(($opcio -eq "Y") -or ($opcio -eq "y")) {$ok="ok"}
                               else{
                                               $opcio = Read-Host 'Incorrect option, continue searching? (Y/N), default option -> N'
                               }
                }
                $ok=""
}

More Information:

Sunday 14 December 2014

[FastToUse] Send mail with Exchange Web Service(EWS) using PowerShell

What?
How to send emails from inside or outside your organization with Exchange 2007/2010/2013/Online using PowerShell.

Fast instructions:
  • First of all you need to download and install the latest Microsoft EWS managed API.
  • After that,
    • Select the right DLL path
    • Replace the username, password, EWS url
    • copy&paste 
    • And run it in PowerShell!
PowerShell Code:

#Import the DLL of Microsoft EWS, choose one
##Version 2.2
Import-module "C:\Program Files\Microsoft\Exchange\Web Services\2.2\Microsoft.Exchange.WebServices.dll"
##For example if your version is 2.1 with x32 it will be
Import-module "C:\Program Files (x86)\Microsoft\Exchange\Web Services\2.1\Microsoft.Exchange.WebServices.dll"


#Create a Service Object and set Exchange 2010_SP2 version.
#If you don't set it, the default one is Exchange 2013
$version = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2
$service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($version)

#Set credentials
$username = "domain\username"
$password = "Your_Password"
$service.Credentials = New-Object Microsoft.Exchange.WebServices.Data.WebCredentials -ArgumentList $username, $password

#EWS URL, if you do not want to use autodiscover
$url = "https://mail.domain.com/EWS/Exchange.asmx"
$service.Url = $url

#Create the Object and send e-mail
$message = New-Object Microsoft.Exchange.WebServices.Data.EmailMessage -ArgumentList $service
$message.From = "mail@domain.com"
$message.ToRecipients.Add('Recipient Name','recipient_1@domain.com')
$message.ToRecipients.Add('Recipient Name','recipient_2@domain.com')
##You can add more recipients, copying the line before
$message.Subject = "This is a test email"
$message.Body = "Message body. Mail from EWS."

#Send email, choose one
##If you want to send it directly
$message.SendAndSaveCopy()
##If you do not want to send it, only to save to drafts and send later
$message.Save()

More information:



Hope it helps!

Monday 8 December 2014

[FastToUse] - Send mail with Exchange Web Service(EWS) using PHP

What?
How to send emails from inside or outside your organization with Exchange 2007/2010/2013/Online using PHP.

Fast instructions:
  • Go to GitHub PHP-EWS and download the libraries
  • Edit the following example and you will be sending e-mails with Exchange in a minutes.
PHP Code:
 <?php  
 //for debugging purpose only, remove in production  
 error_reporting(E_ALL);   
 ini_set( 'display_errors','1');  
 //Load libraries  
 require_once('ExchangeWebServices.php');  
 require_once('NTLMSoapClient.php');  
 require_once('NTLMSoapClient/Exchange.php');  
 require_once('EWS_Exception.php');  
 require_once('EWSType.php');  
 require_once('EWSType/MessageType.php');  
 require_once('EWSType/EmailAddressType.php');  
 require_once('EWSType/BodyType.php');  
 require_once('EWSType/SingleRecipientType.php');  
 require_once('EWSType/CreateItemType.php');  
 require_once('EWSType/NonEmptyArrayOfAllItemsType.php');  
 require_once('EWSType/ItemType.php');  
 class EwsSendEmail  
 {  
      protected function sendEmail()  
      {  
           $server = 'mail.server.com';  
           $username = 'domain\username';  
           $password = '';  
           $ews = new ExchangeWebServices($server, $username, $password);  
           $msg = new EWSType_MessageType();  
           $toAddresses = array();  
           $toAddresses[0] = new EWSType_EmailAddressType();  
           $toAddresses[0]->EmailAddress = 'user@domain.com';  
           $toAddresses[0]->Name = 'Name Surname';  
           $toAddresses[1] = new EWSType_EmailAddressType();  
           $toAddresses[1]->EmailAddress = 'user2@domain.com';  
           $toAddresses[1]->Name = 'Name2 Surname';  
           $msg->ToRecipients = $toAddresses;  
           $fromAddress = new EWSType_EmailAddressType();  
           $fromAddress->EmailAddress = 'mailFrom@domain.com';  
           $fromAddress->Name = 'NameFrom Surname';  
           $msg->From = new EWSType_SingleRecipientType();  
           $msg->From->Mailbox = $fromAddress;  
           $msg->Subject = 'Test missage from PHP code';  
           $msg->Body = new EWSType_BodyType();  
           $msg->Body->BodyType = 'HTML';  
           $msg->Body->_ = '<p style="font-size: 18px; font-weight: bold;">MESSAGE BODY!</p>';  
           $msgRequest = new EWSType_CreateItemType();  
           $msgRequest->Items = new EWSType_NonEmptyArrayOfAllItemsType();  
           $msgRequest->Items->Message = $msg;  
           $msgRequest->MessageDisposition = 'SendAndSaveCopy';  
           $msgRequest->MessageDispositionSpecified = true;  
           $response = $ews->CreateItem($msgRequest);  
           var_dump($response);  
      }  
      function __construct()  
      {  
           $this->sendEmail();  
      }  
 }  
 $page = new EwsSendEmail();  
 ?>  
More information:
Hope it helps!

Saturday 18 October 2014

[FastToUse] A new series of articles

Hi all,

Sometimes we do not want to read large articles explaining all the detailed information about an issue, code or anything else. We want it fast and running in not much time.

This is the reason of these new series of articles which always will have this structure:

  • [FastToUse] - Tag in the subject
  • What? - A short summary about the article
  • Fast Instructions - The instructions, if needed
  • Code/Bug/... - The core of the article with "the information"
  • More information - Links with detailed information if you want to explore more.
let's go to write!

Monday 13 October 2014

Error starting cluster service in a Windows 2008 R2 Cluster

This post born after hours trying to resolve a Cluster issue, and without finding nothing clear in internet!

The problem:
Suddenly the second node of a Windows 2008 R2 Cluster, gets down and there are no way to start it up! The Event Viewer shows the following errors in System log:

Source: Service Control Manager
Event Id:7031
The Cluster Service service terminated unexpectedly. It has done this 1 time(s). The following corrective action will be taken in 60000 milliseconds: Restart Service
Source: Microsoft-Windows-FailoverClustering
Event Id:1069
Cluster resource 'Cluster Disk 1' in clustered service or application 'Cluster group' failed.
Source: Microsoft-Windows-FailoverClustering
Event Id:1573
Node 'node_name' failed to form a cluster. This was because the witness was not accessible. Please ensure that the witness resource is online and available.

Solution:
I tried to restart the server and to stop and start the cluster service with no success.

After that, I checked out the iSCSI configuration in the server and in the SAN, and I found some misconfigurations. After solving it, the problem continues, perhaps this is the origin of the problem, but not all is solved.

My third step is to run cluster service with log using the command:
cluster log /g
You can find the result in %windir%\cluster\reports. I could not see anything useful and went to revise every key of cluster in the regedit configuration at HKLM/Cluster, following some errors found in cluster service log....again no success.

Finally I decide to remove the node from the cluster and rejoin, and SOLVED. Some times its better to start from the end.

To remove a failed node from a cluster:

  1. Run this command from the failed node in elevated Power Shell:
    1. Import-Module FailoverClusters
    2. Clear-clusternode
  2. From the cluster administration MMC > right click on failed server, under nodes > More Actions > Evict
After step 2, you can add the node again into the cluster, and check Event Viewer for additional bugs.

Hope it helps!



Saturday 4 October 2014

How to uninstall Windows Intune

Easy and FAST!

Run this command with elevated privileges:

wmic product where "name like '%intune%'" call uninstall
If you want to do that by the right way, go to Intune admin console.

Friday 28 December 2012

Error installing Exchange 2010 SP2 Rollup 5v2

I managed with this error in Windows 2008 R2 and Exchange 2010 SP2...

When you try to install this update you can find one or all the following errors in the EventLog or in the Windows Installer Log:

 Microsoft Exchange Server - Update 'Update Rollup 5-v2 for Exchange Server 2010 Service Pack 2 (KB2785908) 14.2.328.10' could not be installed. Error code 1603. Windows Installer can create logs to help troubleshoot issues with installing software packages
DEBUG: Error 2826: Control BottomLine on dialog FatalError extends beyond the boundaries of the dialog to the right by 5 pixels The installer encountered an unexpected error while installing this package. This may indicate a problem with this package. The error code is 2826. The arguments are: FatalError, BottomLine, to the right
msgErrorExchangeAdmin = The user who's currently logged on doesn't have sufficient permissions to install this package. You need at least Exchange Server Administrator permissions on the current computer to complete this task.

Basically we have two different problems:
  1. We have a compatibility problem with one update
    • The incompatible update is: Windows Management Framework 3.0 , in my case, at the end of the name, appears "(beta)".
    • You should uninstall it and reboot the system, then continue with step 2.
  2. We need to run the installer with admin privileges
    • Run the update from a Command Line window executed as Administrator
That's all for me!

If you are installing this Rollup update because you need to solve problems related with Retention Tags, Calendar and Tasks I recommend to visit THIS blog.