Thursday, February 16, 2017

Azure Active Directory: connect AAD for management with PowerShell

Azure Active Directory V2 PowerShell Module enables management of Azure Active Directory using PowerShell.
To perform management tasks a connection to AAD domain isrequired. The cmdlet Connect-AzureAD establishes connection to ADD domain.






Started this way the user is prompted to enter credentials for connection

If login succeeds a confirmation is displayed

The connection  can be validated with the cmdlet Get-AzureADDomain

If the user is connected to AAD domain, where he has management privileges - the information about the domain will be displayed. But often following error message is returned instead:

Get-AzureADDomain : Error occurred while executing GetDomains
StatusCode: Forbidden
ErrorCode: Authentication_Unauthorized
Message: User was not found
At line:1 char:1
+ Get-AzureADDomain
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-AzureADDomain], ApiException
    + FullyQualifiedErrorId : Microsoft.Open.AzureAD16.Client.ApiException,Microsoft.Open.AzureAD16.PowerShell.GetDomain


The reason is: the cmdlet GetAzureADDomain has no tenant specified, so the connection was established to a domain, where user has no admin privileges.
To ensure connection to expected AAD domain, the tenant ID must specified in call to Connect-AzureAD cmdlet:


If tenant ID specified properly, the Get-AzureADDomain cmdlet returns confirmation with the same tenant ID as specified in call to Connect-AzureAD

The tenant ID for AAD domain can be obtained from Azure portal


Since only a few Azure users note the tenant ID of their AAD domains rather the domain name, an improvement of PowerShell module for Azure Active Directory is to expect: the parameter TenantDomainName as alternative for TenantId parameter - to enter full domain name instead of GUID based ID.


Saturday, December 10, 2016

Why Microsoft, not Linux - voices from fields

Just read
http://www.cnews.ru/news/top/2016-12-07_linuksoidy_obyasnili_minkomsvyazipochemu_v_rossii

In the meeting in Ministry for Communication of Russia (participants - Ministries of Finance, Security etc., many russian software market key players) were shaped major problem areas, why the migration from Microsoft products to Open Source fails.

There are some of them:
- Active Directory
There are no fully comparable Open Source products, which can replace Microsoft Active Directory. Additionally, any migration to similar Open Source solutions is difficult; slow and expensive.
- ActiveX
Many solutions on Microsoft platform, which are in use by public sector and government organizations, are implemented using ActiveX technology of Microsoft and oriented on Internet Explorer as frontend. Lack of support for this technology and IE at all does the migration of such solutions to Open Source not realistic.
- Office documents
Microsoft Office documents, even Open XML, accompanied by numerous macros and VBA modules cannot be efficiently supported and processed by Open Source. Also used fonts break the optics of tables and diagrams once they are moved from Microsoft to Open Source world.

As for today, there's neither statement nor further instruction published by Ministry for Communication of Russia. The Open Source community and Microsoft didn't post any official statements as well.


Saturday, January 30, 2016

InstallUtilLib Error 1001 Unknown error

...you may see by launching custom setup package (for example, create with Visual Studio 2015 and Microsoft Visual Studio Setup Projects extension).
There are numerous web articles - even marked as [Solved] - for different scenarios.
One - not covered yet - was hit when we launch setup built with .NET Framework 4.5.2 on the platform having 4.5 or 4.5.1.
Once we updated platform with 4.5.2 version of .NET Framework the setup executed successfully.
So check twice the requirements of the setup package and currently installed framework version - neither the setup nor operating system will do that for you - and enjoy!

Wednesday, June 25, 2014

Simulate WebForm submit() in VBScript

 

One of the challenges in support of Web applications is automated testing and monitoring. There are numerous approaches and technologies implementing diverse methods: there is also Visual Studio Load and Web Tests among them. But in some situations usage of external tools and technologies is very limited. Due to usual system limitations and restrictions, good integration with different products and systems and high costs efficiency scripting became the most popular technology for automated Web application tests.

VBScript - as particular scripting technology - allows simulation of user interaction with Web applications.

One of the most common automation tasks is Web form submission. This task requires implementation of HTTP POST request sending form data and usually according simulation of Web control action (submit()).

Basically, there are two ways to implement Web form submission with scripting: automation of Internet Explorer action (control via scripts) and implementation of sequential Web requests, sent directly to Web application (direct scripting of HTTP requests).

Internet Explorer implements its own object model, which can be accessed via scripting and is instrumented to perform required operations: navigate to an URL, call page scripts, submit forms, handle page events etc. Unfortunately, this technology is sometimes hard to use in environments, where Internet Explorer enhanced security is turned on or because of additional security restrictions. Additionally, usage of Internet Explorer automation means one more tier involved into automation process (Internet Explorer application itself), which may impact performance, configuration and functionality of tests.

Direct scripting of Web requests is usually implemented using built-in operating system objects or additional components from Microsoft or 3rd parties. Scripting Msxml component is very popular in this field, has good documentation, eco-system of samples and how-to's.

Msxml component enables script developers to implement HTTP requests: GET, POST.

Here is a typical approach to simulate an ASP.NET WebForm submission using scripting of Msxml component.

The recommended way to investigate and implement automation of Web application interactions includes usage of following tools/sources:

  • Fiddler: Web requests capturing and analyzing tool, (free software, actually owned by Telerik)
  • Notepad or similar editor to write and edit automation scripts
  • OS platform with VBS scripting enabled
  • Msxml component: in the most common case is installed on the platform, but can be downloaded and installed separately

Short description of the approach: implementation of a POST request with form data is not mostly enough to simulate form submission - the submit() action must be included in POST request as well to simulate default form submit control action. For ASP.NET WebForms it means sending of according VIEWSTATE and EVENTVALIDATION data with POST request.

Step 1. Implementing GET request

To obtain the VIEWSTATE and EVENTVALIDATION data for later submit() simulation the GET request must be sent

Set xmlHttp = CreateObject("Msxml2.ServerXMLHTTP.6.0")
Call xmlHttp .open("GET", UrlToWebForm, False)
xmlHttp.send

The UrlToWebForm must contain Url of the WebForm for submission automation. In doubt start Fiddler, open Internet Browser, navigate to WebForm and monitor Url listed in Fiddler session list

responseText = xmlHttp.responseText

The responseText contains the VIEWSTATE and EVENTVALIDATION data, which must be extracted to reuse in POST request

REM extract VIEWSTATE
Function GetViewState(response)

idxStart = InStr(1,response,"__VIEWSTATE")
idxStart = InStr(idxStart,response,"value=") + 7
idxEnd = InStr(idxStart + 2, response, """")
GetViewState = Mid(response,idxStart, idxEnd - idxStart)

End Function

REM extract EVENTVALIDATION
Function GetEventValidation(response)

idxStart = InStr(1,response,"__EVENTVALIDATION")
idxStart = InStr(idxStart,response,"value=") + 7
idxEnd = InStr(idxStart + 2, response, """")
GetEventValidation = Mid(response,idxStart, idxEnd - idxStart)

End Function

Step 2. Construct POST request to submit form data

The in step 1 instantiated object can be reused for form submission using POST request

Call xmlHttp .open("POST", UrlToWebForm, False)

Add request header declaring sent data as form submission

xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

Construct form submission data

formData = "myControl1=data1&myControl2=data2"

The content of form submission data can be easily obtained using Fiddler the same way as described above

Add VIEWSTATE and EVENTVALIDATION data, be aware of adding this data urlEncoded:

formData = formData & "&__VIEWSTATE=" & urlEncode(viewState) & "&__EVENTVALIDATION=" & urlEncode(evtValidation))

URL encode function is not contained in standard scripting environment and must be implemented or imported separately. Ask for code snippet if want to use my code.

And finally send the request

xmlHttp.send(formData)

That's it! The form data is submitted and the ASP.NET WebForm gets default button clicked event to process submitted data on the server side properly.

Enjoy!

Tuesday, March 04, 2014

“The World Wide Web Publishing Service (WWW Service) did not register the URL prefix http://*:443/ for site x. The site has been disabled. The data field contains the error number.” when you try to start an IIS WebSite on Windows 8/8.1

 

Starting a custom WebSite with https (Port 443) binding you may encounter following problem:

image

Event viewer says

The World Wide Web Publishing Service (WWW Service) did not register the URL prefix https://localhost:443/ for site 2. The site has been disabled. The data field contains the error number.

The problem is: one of currently running programs uses the port and doesn’t let IIS to start the WebSite. Which program does it .- displays TcpView tool from Sysinternals:

image

In this case it is Skype: quit it – not just log out etc., you have to quit the Skype process to release the port. Then restart WebSite – and enjoy!

BTW: if you start Skype after the WebSite started – it starts as well and finds another port to communicate: you do not have to restrict you Windows comfort working without Skype while using local IIS WebSite with https binding

Saturday, November 30, 2013

ASP.NET Web Application crash, faulting module KERNELBASE.dll, exception code 0xe053534f

 

Stressing your ASP.NET application you may bring the whole Website out-of-order. The application pool will stop after numerous crashes: look for system event log entry

Application pool '<your pool name>' is being automatically disabled due to a series of failures in the process(es) serving that application pool.

Referring application log event log entries are:

Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7afa2
Faulting module name: KERNELBASE.dll, version: 6.1.7601.18229, time stamp: 0x51fb1677
Exception code: 0xe053534f
Fault offset: 0x000000000000940d
Faulting process id: 0x%9
Faulting application start time: 0x%10
Faulting application path: %11
Faulting module path: %12
Report Id: %13

and

Fault bucket , type 0
Event Name: APPCRASH
Response: Not available
Cab Id: 0

Problem signature:
P1: w3wp.exe
P2: 7.5.7601.17514
P3: 4ce7afa2
P4: KERNELBASE.dll
P5: 6.1.7601.18229
P6: 51fb1677
P7: e053534f
P8: 000000000000940d
P9:
P10:

Attached files:

These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_w3wp.exe_ffdd7dc3338f9bc64b4c591c349d26eadb9c3c_11b74904

Analysis symbol:
Rechecking for solution: 0
Report Id: 922480ec-59e6-11e3-b316-00155d49e7d5
Report Status: 4

There are some useful articles how to debug such crash. One of my favorite is this article from Tess Fernandez:

Debugging a .NET crash with rules in Debug Diag

If you use SQL database for ASP.NET state management, you may try this quick fix:

  • go to ASPState database (for example, using SQL Management Studio)
  • clear ASPStateTempSessions table:

      delete FROM [ASPState].[dbo].[ASPStateTempSessions]

This fix helped us to bring the pool to run again.

Enjoy

Wednesday, June 12, 2013

Search and replace using PowerShell

 

Last week we were faced to a problem: there are numerous files distributed in hierarchy of folders on the disk and we are required to replace a pattern string in each of these files to a specified replacement string. (In fact, we had to add quickly hardwired location parameters to all the AJAX ModalPopupExtender controls in an ASP.NET solution).

The challenge is: the files cannot be copied outside of the target machine, processed and copied back – all the processing MUST occur on the target box using only on-board tools. And there aren’t any built-in software in Windows (Server 2008 R2) providing such functionality like S&R, Visual Studio or other similar tools, enabling recursive search and replace operations.

Some of us started to wipe dust off their DOS command line skills and write some batch files. But the better solution is in use of built-in PowerShell.

Start PowerShell and launch following command:

dir –r {fileseach pattern}| %{ $x = get-content $_ ; $x = $x -replace ({search pattern}, {replacement pattern}) ; set-content $_ $x }

For example:

dir -r *.aspx| %{ $x = get-content $_ ; $x = $x -replace ("ModalPopupExtender ID", "ModalPopupExtender X=""100"" Y=""100"" ID") ; set-content $_ $x }

replaces string

ModalPopupExtender ID

with

ModalPopupExtender X="100" Y="100" ID

in all .aspx files in current folder and below

This makes from

<ajax:ModalPopupExtender ID=”mpe1” …/>

the string

<ajax:ModalPopupExtender X="100" Y="100" ID=”mpe1” …/>

So all the processing occurred on the target box without any need to copy the files to equipped machine, process them and copy back. Also without any need to install/deploy additional software to the target machine specially to perform desired processing.

Next time you need to replace some string with another one in a number of files distributed in recursive subfolders using only built-in software of Windows OS – do not panic: use pattern PowerShell command from above and enjoy!

Monday, June 10, 2013

Microsoft Azure VM billing model changed

Scott Guthrie announced at TechEd 2013 changes in VM billing model: you pay only for running - and not
as mentioned before also for stopped VMs.
So please disregard my previous post and enjoy!

Wednesday, May 01, 2013

Microsoft Windows Azure IaaS: delete not used VM to avoid unnecessary costs

 

Just a short hint, which can protect against unexpected costs.

Once you decide not to use a virtual machine you created on Microsoft Windows Azure, you should delete it from your account – and not just shut down. Do not be afraid, the virtual disk this VM used will not be destroyed – it is still existing in storage services part of your account. Only not used VM can and must be deleted.

The billing model of Microsoft Windows Azure is constructed to bill for a VM even if the machine isn’t running. That’s similar to car rent: if you rent a car, you have to pay the rent even if the car is just standing on the park place. No gasoline/mileage costs (computing, networking etc. in cloud computing terms) , but the rent.

So to avoid the bills for an unused VM just delete it after shut down. Remember: you can re-create this VM any time as long as the VHD this VM used is kept in the storage of your account (check the storage container(s) ).

This does mean: you pay only for the VHD left after the VM is deleted – this blob is residing in the storage and is calculated regarding your billing model. The bigger is the VHD the more you have to pay. So if you do not plan to re-create the VM (re-use it) later, you’d better delete the VHD too. Anyway, the costs for “parked” and not used VHD in the storage are incomparable lower than the costs of a not used but not deleted VM.

Enjoy!

Wednesday, April 24, 2013

Retrieving the COM class factory for component with CLSID {CF4CC405-E2C5-4DDD-B3CE-5E7582D8C9FA} failed due to the following error: 800703fa

 

Once you use WMI services in your management code, you may suddenly receive following error message:

Retrieving the COM class factory for component with CLSID {CF4CC405-E2C5-4DDD-B3CE-5E7582D8C9FA} failed due to the following error: 800703fa.
   at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
   at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(Type serverType)
   at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(Type serverType, Object[] props, Boolean bNewObj)
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
   at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.Management.MTAHelper.CreateInMTA(Type type)
   at System.Management.ManagementPath.CreateWbemPath(String path)
   at System.Management.ManagementPath..ctor(String path)
   at System.Management.ManagementClass..ctor(String path)

The reason is: the WMI performance object you want to access is not more properly registered or the registration is damaged (for example, due to lack of buffer space).

To ensure the cause of the error use the WMI diagnostic tool as mentioned in:

http://support.microsoft.com/kb/926640

The tool contains a VBS script WMIDiag.vbs.
IMPORTANT! Start the script using command line:

>cscript.exe WMIDiag.vbs

to receive proper tool output.
The output consist of (at least) two files: the report file WMIDIag-…-REPORT.TXT and the log file WMIDiag-….LOG. Both files contain date/time stamp and short machine info (OS Version etc.) in their names and located in %TEMP% folder of current user (i.e. C:\USERS\ADMINISTRATOR\APPDATA\LOCAL\TEMP if ran as administrator).

The report file contains mostly relevant information about the error’s cause, for example:

38819 09:29:32 (0) ** - Root/WMI, SystemConfig_CPU, 0x80041002 - (WBEM_E_NOT_FOUND) Object cannot be found.
38820 09:29:32 (0) **   MOF Registration: ''
38821 09:29:32 (0) ** - Root/WMI, SystemConfig_LogDisk, 0x80041002 - (WBEM_E_NOT_FOUND) Object cannot be found.
38822 09:29:32 (0) **   MOF Registration: ''
38823 09:29:32 (0) ** - Root/WMI, SystemConfig_Power, 0x80041002 - (WBEM_E_NOT_FOUND) Object cannot be found.
38824 09:29:32 (0) **   MOF Registration: ''
38825 09:29:32 (0) ** => When a WMI performance class is missing (i.e. 'Win32_PerfRawData_TermService_TerminalServices'), it is generally due to
38826 09:29:32 (0) **    a lack of buffer refresh of the WMI class provider exposing the WMI performance counters.
38827 09:29:32 (0) **    You can refresh the WMI class provider buffer with the following command:
38828 09:29:32 (0) **
38829 09:29:32 (0) **    i.e. 'WINMGMT.EXE /SYNCPERF'

The hint about refreshing the class provider requires following updates:

- the command is

WINMGMT.EXE /RESYNCPERF

- you have to restart your process accessing the WMI provider (i. e. if your ASP.NET application uses WMI provider, you have to restart the worker process or just launch iisreset).

Enjoy!

Sunday, February 10, 2013

Enable time synchronization for Hyper-V guest VM

It’s a very good idea to enable time synchronization between Hyper-V host and guest VM. Otherwise, you may run into risk, that neither RDP session not file sharing can be used for communication with the VM. The error message may look like:

 

"Remote Desktop cannot verify the identity of the remote computer because there is a time or date difference between your computer and the remote computer.  Make sure your computer's clock is set to the correct time and then try connecting again.  If the problem occurs again, contact your network administrator or the owner of the remote computer."

 

Yes, you should connect then the console on the VM and check and setup the date/time manually. But you can let the system do it automatically for you.

Open Hyper-V settings for the VM and check the “Integration services” settings: which services are enabled

image

Ensure “Time synchronization” service is enabled:

image

Enjoy!

Sunday, February 03, 2013

Windows Phone 8: external USB disk is back!

Just a few days using my new Windows Phone 8 device: the first and breaking change – the phone as external disk is back.

image

No need to exercise with Zune to download photos and videos from the device – as required by Windows Phone 7.x.

I really enjoy revival of this feature – do you?

Thursday, January 24, 2013

"Unable to create offline join information" on joining domain from Windows 7, Windows 8 or Windows Server 2008 R2 machine

Joining domain you may enter correct domain and administrator account data, but finally get an error:

"Unable to create offline join information"

View into ADSI users and computers applet on the domain controller shows, that computer account was created and is already listed, but the victim machine still isn’t joined to domain.

(Possible) resolution: check for any anti virus software running on the machine to be joined. In our case it was McAfee – once we’ve disabled it, the join succeeded immediately, and we enjoy Smile

"No mapping between account names and security IDs was done" error message while SQL Server 2008 Setup on a Hyper-V VM

While installing SQL Server 2008 on a Hyper-V VM you may encounter following problem: setting accounts for SQL Server services you’ll get an error box with message

"No mapping between account names and security IDs was done"

The account data: domain, login, password are correct, but the message comes over and over again and doesn’t let continue the setup.

In this situation there’s a good time to check if the VM to install SQL Server is using a copied VHD. Once the VHD is just copied (for example, you are installing a domain, setup a blank VHD and copy it to deploy different domain member machines) you have to change the machine ID for each (!) VM to deploy.

To change the ID before installing SQL Server 2008 in the VM with copied VHD use the built-in Windows tool SysPrep.

image

Using SysPrep on the VM do not forget to check the box “Generalize”. You will need to enter keyboard, location and probably some additional settings on the next VM start.

Enjoy!

PS: BTW, the best way is still to setup the machine fro SQL Server from scratch, I guess.

UPD: Good article here: http://macraem.wordpress.com/2010/02/25/no-mapping-between-account-names-and-security-ids-sql-server-install-and-sysprep-generalize/

Sunday, January 20, 2013

Using CoreConfig on Windows Hyper-V Server 2012

 

Microsoft Hyper-V Server 2012 is a great opportunity to virtualize the whole IT environment for low cost (free download, free-of-charge activation – as for today).

As for core server there aren’t any window based management tools, the administrator may want to learn and exercise console and powershell commands. Alternatively, there’s an administration package named CoreConfig at codeplex: http://coreconfig.codeplex.com/

After copy to the target box one may encounter problems starting the configuration tools. The reason is based on changed command set for Windows Server 2012 and described here:

http://coreconfig.codeplex.com/discussions/397446

So, once you downloaded the content of the package to your fresh installed Hyper-V Server 2012 box, the next step is: find “oclist” string and replace it by “dism” in following files:

  • Start_CoreConfig.wsf
  • CoreConfig.ps1
  • Networking.ps1
  • Roles.ps1

After the files are changed you can start the Start_CoreConfig.wsf as usual (as on Hyper-V Server 2008 R2) – or launch powershell and start single modules.

If you get an error message

"File cannot be loaded because the execution of scripts is disabled on this system"

you’ll need to set execution policy to unrestricted with following powershell command:

Set-ExecutionPolicy Unrestricted

After the steps are done you should be able to start the configuration modules as expected:

image

Enjoy!