Advertisements

Powershell error – The term ‘Login-AzureRmAccount’ is not recognized as the name of a cmdlet, function, script file, or operable program


 
If you are new to PowerShell like me then you would have encountered this ans similar errors.

Recently while executing one PowerShell script to connect to Azure Resource Manager I faced following error:

XyzPSScript.ps1 : The term ‘Login-AzureRmAccount’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
+ CategoryInfo : ObjectNotFound: (Login-AzureRmAccount:String) [XyzPSScript.ps1], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException,XyzPSScript.ps1

This error means that you do not have Azure PowerShell module installed on your system or server.
 

–> So, let’s see how to install the dependent modules.
 

1. Connect to PowerShell from command prompt (CMD) in Admin mode:

c:\> powershell.exe

Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

 

2. Check the version of PowerShell:

PS c:\> $PSVersionTable.PSVersion

Major Minor Build Revision
—– —– —– ——–
5 1 14409 1005

 

3. Run the below command to check if you have PowerShellGet installed on your system:

PS c:\> Get-Module PowerShellGet -list | Select-Object Name,Version,Path

Name Version Path
—- ——- —-
PowerShellGet 1.0.0.1 C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PowerShellGet.psd1

 

4. Now we can easily install the Azure PowerShell from the PowerShell Gallery by runnign following command:

PS C:\> Install-Module AzureRM

NuGet provider is required to continue
PowerShellGet requires NuGet provider version ‘2.8.5.201’ or newer to interact
with NuGet-based repositories. The NuGet provider must be available in
‘C:\Program Files\PackageManagement\ProviderAssemblies’ or
‘C:\Users\essensed\AppData\Local\PackageManagement\ProviderAssemblies’. You can
also install the NuGet provider by running ‘Install-PackageProvider -Name
NuGet -MinimumVersion 2.8.5.201 -Force’. Do you want PowerShellGet to install
and import the NuGet provider now?
[Y] Yes [N] No [S] Suspend [?] Help (default is “Y”): Y

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this
repository, change its InstallationPolicy value by running the Set-PSRepository
cmdlet. Are you sure you want to install the modules from ‘PSGallery’?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help
(default is “N”):Y

On every prompt type ‘Y’ to proceed ahead.

While Installing the module you will see this screen:

5. Finally you just need to import the AzureRM module:

PS C:\> Import-Module AzureRM

This import command will not give any output, and you may proceed with the PS prompt.


Advertisements

Error – The following feature couldn’t be installed – .NET Framework 3.5


 
I got error this message on a pop window while running a new application after installing it on my Windows Server 2012 Azure VM.


 

This feature can be installed from the “Windows Server Manager”, you will see its icon on the task bar besides the Start button, as shown below. Or you can directly type “servermanager” on CMD or Run prompt.

Click on the “Add Roles and Features”


 

A new window will open up “Add Roles and Features Wizard”, click Next.
On “Installation Type”, click Next again.
On “Server Selection”, select the current/default server and click Next.
On “Server Roles” click Next.
Now on Features select the “.NET Framework 3.5 Features” option, an click Next.
On Confirmation page you will see “Specify an alternate source path” link, click on that link, and a new window opens up, as shown below:


 

Here on the highlighted text box you need to specify the “side-by-side (SxS) folder” path of the OS installation media. So, if you have an ISO file you can mount it or if you have a dump of the setup, provide the path form the respective location. Finally click on Install button.
 

If you are on an Azure Windows VM, you will not have access to the ISO or installation media. In this case you can simply run a Windows Update from Control Panel–> System and Security –> Windows Update.


Categories: MS.net, Windows

Parsing nested JSON in customized SQL Tabular format – MSDN TSQL forum


 
–> Question:

Basically I have a JSON file output that I want to put into a SQL table, but no matter what syntax I try it doesn’t seem to be working.

This is my sample JSON file contents:

{
   "destination_addresses":[
      "Orlando, FL, USA"
   ],
   "origin_addresses":[
      "New York, NY, USA"
   ],
   "rows":[
      {
         "elements":[
            {
               "distance":{
                  "text":"1,072 mi",
                  "value":1725756
               },
               "duration":{
                  "text":"15 hours 40 mins",
                  "value":56405
               },
               "status":"OK"
            }
         ]
      }
   ],
   "status":"OK"
}

What I want is a SQL table that has 2 columns, column 1 will be item names (Destination Address,Origin Address, Distance Text, Distance Value, Duration Text & Duration Value) and column 1 will be the actual data.

I can get OPENJSON to do what I want for destination address & origin address but when I try and using OPENJSON to read the nested items that exist in ‘rows – > elements’ I can’t seem to pick them up. Can anyone help with the right syntax?
 

–> Answer:

declare @str varchar(4000) = 
N'{
   "destination_addresses":[
      "Orlando, FL, USA"
   ],
   "origin_addresses":[
      "New York, NY, USA"
   ],
   "rows":[
      {
         "elements":[
            {
               "distance":{
                  "text":"1,072 mi",
                  "value":1725756
               },
               "duration":{
                  "text":"15 hours 40 mins",
                  "value":56405
               },
               "status":"OK"
            }
         ]
      }
   ],
   "status":"OK"
}'

SELECT 
	CONCAT_WS(' ',Destination_Addresses, Origin_Addresses,Distance_Text,
		Distance_Value,Duration_Text,Duration_Value) as Col1
	,@str as Col2
FROM OPENJSON (@str)
WITH (
    Destination_Addresses    VARCHAR(1000) '$.destination_addresses[0]',
    Origin_Addresses   VARCHAR(1000) '$.origin_addresses[0]',
    Distance_Text    VARCHAR(1000) '$.rows[0].elements[0].distance.text',
    Distance_Value   VARCHAR(1000) '$.rows[0].elements[0].distance.value',
    Duration_Text    VARCHAR(1000) '$.rows[0].elements[0].duration.text',
    Duration_Value   VARCHAR(1000) '$.rows[0].elements[0].duration.value'
) AS Orders

Microsoft hosts its first-ever Accessibility Summit in India to enhance technology access for people with disabilities


 
Continues its efforts to bridge technology divide and drive digital inclusion to empower people to achieve more


(From L-R)

Dr. Jitender Aggarwal, Founder & CEO Sarthak Educational Trust, Shri M. Jagadeeshwar, IAS, Department of Women and Child Development, Government of Telangana,

Shri Navreet Kang, Secretary, Department of Empowerment of Persons with Disabilities, Ministry of Social Justice and Empowerment, Government of India,

Shri Jayesh Ranjan, IT Secretary, Department of IT, Electronics & Communication, Government of Telangana,

Madhu Khatri, Associate General Counsel and Accessibility Lead, Microsoft India

… at the first-ever Microsoft Accessibility Summit in India that is focused on enhancing technology access for people with disabilities.
 

Hyderabad, 30 May 2017: Microsoft India today hosted its first-ever Accessibility Summit (#ThinkAccessAbility) in the country to enhance technology access for people with disabilities. The summit aimed at demonstrating the business value of accessible technology for organizations, the need for a collaborative effort as well as assessing policy’s role in creating an accessible India. The summit brought together leaders from the government, non-profit organizations, filmmakers, entrepreneurs and budding technologists to present their views and best practices around accessibility and technology’s potential in aiding inclusion.
 

Shri Navreet Kang, Secretary, Department of Empowerment of Persons with Disabilities, Ministry of Social Justice and Empowerment, Government of India said, “We believe that inclusion of persons with disabilities is imperative for India’s growth. It is therefore, critical that we empower them with equal access and opportunity. We look forward to public-private partnerships that can enable better social inclusion and help people with disabilities achieve more.”
 

Speaking at the summit, Shri Jayesh Ranjan, IT Secretary, Department of IT, Electronics & Communication, Government of Telangana said, “Our vision is to ensure that persons with diverse abilities have equal access to the physical environment, transportation, information and communication technologies, and to other facilities and services. The Microsoft Accessibility Summit provides an ideal platform to bring together policymakers and influencers to understand the policy environment and chart a direction for making life, experiences and opportunities accessible to all.”
 

A platform to discuss, imagine and bring new perspectives for innovative use of technology
Through a series of constructive sessions, the conference focused on the role of technology in creating accessible businesses, scalable and sustainable models for skilling youth with disability. It also examined how assistive technologies can help in treating Autism Spectrum Disorders and Special Learning Disabilities (SLD). There was a special focus on the need for regulatory policies for innovation on accessible technologies and inclusive hiring practices. These interactions also provided insights into regulations, specifications and standards in terms of accessibility along with an understanding of optimization of existing hardware and software configuration to drive accessibility. Shri M. Jagadeeshwar, IAS, Department of Women and Child Development, Government of Telangana also contributed to the discussions as part of the summit.
 

Technology innovations for driving accessibility
The summit featured unique technology-based projects that empower people with disabilities. These included innovations from non-profit organizations, assistive technologies developed by Microsoft partners as well as Microsoft solutions. A young team of three students from IIT Kharagpur showcased White Cane, a personal assistant device for the visually impaired, which they have developed as part of Microsoft Imagine Cup.
 

According to Dr. Jitender Aggarwal, Founder & CEO Sarthak Educational Trust, “Accessibility is one of the dire necessities for creating an inclusive environment. The difference between the able bodied and disabled is not so much because of physical challenges, as due to the fact that everything around us is designed from the perspective of able bodied people only. In such a scenario, accessible and adaptive technologies act as a support system to promote inclusion and empowerment of persons with disabilities.”
 

Speaking at the conference, Madhu Khatri, Associate General Counsel and Accessibility Lead, Microsoft India said, “At Microsoft we believe there are no limits to what people can achieve when technology reflects the diversity of everyone who uses it. We are committed to transparency, accountability, and inclusion in our products and our culture, and we are deeply inspired by the opportunity to work with others around the world to explore what’s possible. A market-driven ecosystem is the best environment for encouraging greater accessibility for all users. The Summit is a significant step forward in advancing our efforts towards sensitizing stakeholders and partners on the need for the business and social value of accessibility.”
 

Please find more information to Microsoft’s approach to accessibility on Microsoft Accessibility Website and see Microsoft India’s video on Empowering for Inclusion.
 

About Microsoft India
Founded in 1975, Microsoft (Nasdaq “MSFT” @microsoft) is the leading platform and productivity company for the mobile-first, cloud-first world, and its mission is to empower every person and every organization on the planet to achieve more. Microsoft set up its India operations in 1990. Today, Microsoft entities in India have over 8,000 employees, engaged in sales and marketing, research and development and customer services and support, across 11 Indian cities – Ahmedabad, Bangalore, Chennai, New Delhi, Gurugram, Noida, Hyderabad, Kochi, Kolkata, Mumbai and Pune. Microsoft offers its global cloud services from local datacenters to accelerate digital transformation across Indian start-ups, businesses, and government agencies. In 2016, Microsoft opened one of its eight Cyber Security Engagement Centers in the country, to address security needs of both public and private sectors.
 

For further information, contact
Anindita Phukan
Microsoft Corporation India Pvt. Ltd.
Email: Anindita.phukan@microsoft.com
+919811402847

Dhairya Chaudhry
Edelman India
dhairya.chaudhry@edelman.com
+9199689 84563
 

FOR MORE INFORMATION:
Microsoft India news: http://news.microsoft.com/en-in/
Log onto: http://microsoft.com/india/news
Follow us on: Twitter | Facebook


Categories: Microsoft

Preparing for Exam 70-761, Querying Data with Transact-SQL | Certification


 
This exam (70-761) will earn you MCP in SQL Server 2016 Querying Data with Transact-SQL. It is 1 out of the 2 exams to earn the “MCSA: SQL 2016 Database Development” certification. I will discuss about the other “Exam 70-762, Developing SQL Databases” in my next post.
 

So, let’s go and understand this exam, links to study material and how to prepare for this.
 

–> This exam is targeted for students or professionals who want to learn about Transact-SQL or simply T-SQL, which includes:
1. Know about SQL Server and its components
2. Write single/multi table SELECT statements, with SET and Predicate logic
3. Apply Filtering, Sorting, JOIN, etc with SQL Queries
4. Write DDL, DML SQL Statements to Store and Retrieve data to & from Tables
5. Create Views, Stored Procedures, Functions, etc
6. Use inbuilt Functions and Transform data
7. Work with SQL Datatypes, Variables, Conditions, Loops and T-SQL code/scripts
 

–> The exam is divided into multiple modules:

1. Introduction to Microsoft SQL Server 2016
    – The Basic Architecture of SQL Server
    – SQL Server on-premise and cloud-based Editions and Versions
    – Getting Started with SSMS

2. Introduction to T-SQL Querying
    – Introducing T-SQL with basic SELECT Statements
    – Understanding Sets and SET based Queries in relational DBs
    – Understanding Predicate Logic to Filter Data
    – Understanding the Logical Order of Operations in SELECT statements

3. Writing SELECT Queries
    – Writing Simple SELECT Statements, its structure and format
    – Eliminating Duplicates with DISTINCT clause
    – Using Column and Table Aliases
    – Writing Simple CASE Expressions

4. Querying Multiple Tables
    – Understanding Joins
    – Querying with Inner Joins, Outer Joins, Cross Joins and Self Joins

5. Sorting and Filtering Data
    – Sorting Data with ORDER BY clause
    – Filtering Data with WHERE clause Predicates
    – Filtering Data with TOP and OFFSET-FETCH
    – Working with Unknown/Missing Values or three-valued logic (NULL)

6. Working with SQL Server 2016 Data Types
    – Introducing SQL Server 2016 Data Types
    – Working with Character Data
    – Working with Date and Time Data
    – Working with data types conversion

7. Using DML to Modify Data
    – Inserting Data with INSERT and SELECT INTO statements
    – Modifying and Deleting Data with UPDATE, MERGE, DELETE, and TRUNCATE statements

8. Using Built-In Functions
    – Writing Queries with Built-In Functions
    – Using Conversion Functions (CAST & CONVERT)
    – Using Logical Functions
    – Using Functions to Work with NULL

9. Grouping and Aggregating Data
    – Using built-in Aggregate Functions
    – Using the GROUP BY Clause
    – Filtering Groups with HAVING

10. Using Subqueries
    – Writing Self-Contained Subqueries
    – Writing Correlated Subqueries
    – Using the EXISTS Predicate with Subqueries

11. Using Table Expressions
    – Using Views
    – Using Inline Table-Valued Functions (TVFs)
    – Using Derived Tables
    – Using Common Table Expressions (CTEs)

12. Using Set Operators
    – Writing Queries with the UNION operator (and UNION ALL)
    – Using EXCEPT and INTERSECT operators
    – Using APPLY operators (CROSS APPLY and OUTER APPLY)

13. Using Windows Ranking, Offset, and Aggregate Functions
    – Creating Windows with OVER clause with partitioning, ordering, and framing
    – Exploring Window Aggregate and Ranking Functions

14. Pivoting and Grouping Sets
    – Writing Queries with PIVOT and UNPIVOT
    – Working with Grouping Sets, CUBE and ROLLUP Subclauses
    – Using the GROUPING_ID function

15. Executing Stored Procedures
    – Querying Data with Stored Procedures
    – Creating Simple Stored Procedures
    – Passing Parameters to Stored procedures
    – Stored Procedures with output parameters
    – Working with Dynamic SQL

16. Programming with T-SQL
    – T-SQL Programming Elements (Variables, Batches, )
    – Using variables in a Dynamic SQL Statement
    – Controlling Program Flow (IF-ELSE condition, WHILE loop)
    – Working with Synonyms

17. Implementing Error Handling
    – Implementing T-SQL error handling with TRY/CATCH block
    – Implementing structured exception handling with THROW keyword

18. Implementing Transactions
    – Transactions and the database engines
    – Differences between batches and transactions
    – Controlling transactions with BEGIN, COMMIT, and ROLLBACK
    – Error handling with the CATCH block
    – Use of SET XACT_ABORT while handling Transactions


 
Microsoft official link to this exam: https://www.microsoft.com/en-in/learning/course.aspx?cid=20761

Book available as a Training Kit on Amazon, buy it.

SQL Server 2016 articles on my blog: https://sqlwithmanoj.com/sql-server-2016-articles/