Loading...

Follow RidiCurious.com | Ridiculously Curious look to .. on Feedspot

Continue with Google
Continue with Facebook
or

Valid

Hello, Today in this blog post we are going to take a look into, “How to Customize TypeNames on PowerShell objects”. Following are 3 approaches I know, let me know if there are any more.

  1. Using PSTypeNames property

    All PowerShell objects have by default have the PSTypeNames property on them, which is an Array holding datatype names of the object. We will go ahead and Clear() all the elements of this Array and add a custom datatype name using the Add(). Now if you run Get-Member on this object, you’ll observe that the Type name has been changed.

  2. Using PSObject Adapter

    PowerShell objects are often adapted from raw .Net objects into an adapted view, this is done by a PSObject adapter available on all PowerShell objects and accessible through Dot ( . ) operator as PSObject property. Which also has a TypeName property holding an Array of all the datatype names of the respective object. We will access this property and Insert() an element (i.e, Custom TypeName) at first index of the Array. Now the Get-Member on this object will return the custom type name in the results.

  3. Using a HashTable

    Converting Hashtables to PSCustomObject is quite popular among PowerShell users because it is very easy to use. But you can also add another key-value pair with key as PSTypeName and value as your custom type name, before type casting it to [PSCustomObject] to add a custom type name as demonstrated in the following example.

If you like this article read more similar articles under ‘N – Ways to’ category


~ Author of “PowerShell Guide to Python“,  and currently writing a Book on “Windows Subsystem for Linux (WSL)

All my books are available as a discounted bundle:

    1. PowerShell Guide to Python : This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for longer time.
    2. Windows Subsystem for Linux (WSL) Keywords, definitions, and problems WSL solve and how it works under the hoods. From download to setup to interoperability this book even covers details like the architecture of Windows subsystem for Linux and new features in WSL 2 with some wonderful use cases.

Subscribe to our mailing list
* indicates required
Email Address *

The post 3 Ways to Create Custom TypeNames on PowerShell Objects appeared first on Ridicurious.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Hey, Once again with a quick blog post something very generic but, useful for me when I am testing or fiddling around various Linux distribution packages on WSL. I am currently writing a book on Windows Subsystem for Linux and this is very handy for that.

WSL distribution packages can be easily downloaded with PowerShell, using the Invoke-WebRequest cmdlet and passing the download URL as an argument. Following is a sample command to download Ubuntu 18.04 application package, similarly, other URLs mentioned in the previous sections can be used to download various flavors of WSLs. The progress bar is intentionally muted by changing the progress preference variable $ProgressPreference = 'SilentlyContinue' this will download the package quicker.

This will start downloading WSL Distro for Ubuntu 18.04 as a file: wsl-ubuntu-1804.appx. Once the download is complete. you can use Invoke-Item Cmdlet on the .appx file in the current working directory to run launch the application installation GUI, then click next to install.
Alternatively, all the web URLs can be iterated and downloaded one by one using the PowerShell cmdlet: Add-AppxPackage to add each application package (*.appx) to the user profile.


~ Author of “PowerShell Guide to Python“,  and currently writing a Book on “Windows Subsystem for Linux (WSL)

All my books are available as a discounted bundle:

    1. PowerShell Guide to Python : This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for longer time.
    2. Windows Subsystem for Linux (WSL) Keywords, definitions, and problems WSL solve and how it works under the hoods. From download to setup to interoperability this book even covers details like the architecture of Windows subsystem for Linux and new features in WSL 2 with some wonderful use cases.

Subscribe to our mailing list
* indicates required
Email Address *

The post Download & Install All WSL Distros with PowerShell appeared first on Ridicurious.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Hi Guys, this is a quick blog post on something that I learned today on PowerShell.

Ashamed to say this… but I have never used -ErrorAction Ignore before, until today when I realized that one of the old scripts written by a colleague started to fail backward compatibility checks on Windows 7 / PowerShell v2.0. Within minutes into the google search, I found that it only works on PowerShell v3.0 and above, here is the article on Microsoft Docs for your reference.

So, there are a total of 6 action preferences, as you can see in the following screenshot after getting names in the enum: [System.Management.Automation.ActionPreference]

And usually, to suppress errors we use -ErrorAction SilentlyContinue that will not display any errors, but it will be added to $Error Automatic variable,  which is an array of error objects that represent the most recent errors occurred in PowerShell and can be used to check errors at a later stage of execution.

But, if I use -ErrorAction Ignore then, Errors are still suppressed but, now they are not added to the $Error Array variable. This can come very handy when we want to exclude errors thrown by specific cmdlets from the automatic variable: $Error . Following are the commands and screenshot for your reference:



~ Author of “PowerShell Guide to Python“,  and currently writing a Book on “Windows Subsystem for Linux (WSL)

All my books are available as a discounted bundle:

  1. PowerShell Guide to Python : This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for longer time.
  2. Windows Subsystem for Linux (WSL) : Keywords, definitions, and problems WSL solve and how it works under the hoods. From download to setup to interoperability this book even covers details like the architecture of Windows subsystem for Linux and new features in WSL 2 with some wonderful use cases.

Subscribe to our mailing list
* indicates required
Email Address *

The post Today I Learned: -ErrorAction Ignore appeared first on Ridicurious.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Infrastructure as code tools enables development and IT operations teams to consistently deploy resources across various cloud computing platforms.

One such tool is Pulumi, an open source and multi-cloud development platform that enables IaC deployment practices, as well as version control. The tool supports multiple languages, such as JavaScript, Python and Go. Engineers can use their preferred programming language to define, create and update cloud services on AWS, Microsoft Azure and Google Cloud Platform, rather than have to learn and use a cloud-native configuration tool like Azure Resource Manager or AWS CloudFormation.

Pulumi is an alternative to Terraform, which relies on a custom, domain-specific language or the HashiCorp Configuration Language. Since Pulumi forgoes this prerequisite, users can start to write infrastructure configurations with less upfront training.

Read More at TechTarget.com
My new book: PowerShell Scripting Guide to Python

This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for a longer time.

“Use what you know to learn what you don’t. ” also known as Associative learning.

Book follows a comparative method to jump-start readers journey in Python, but who is the target audience? and who should read this book –

  • Any System Administrator who wants to step into Development or Programming roles, and even if you don’t want to be a developer, knowledge of another scripting language will make your skill set more robust.
  • Python Developers who want to learn PowerShell scripting and understand its ease of user and importance to manage any platform.

Python is one of the top programming languages and in fast-changing IT scenarios to DevOps and Cloud to the future – Data ScienceArtificial Intelligence (AI) and Machine Learning Python is a must know.

But this PowerShell Scripting guide to Python would be very helpful for you if you already have some knowledge of PowerShell

NOTE! This is a Leanpub “Agile-published” book. That means the book is currently unfinished and in-progress. As I continue to complete the chapters, we will re-publish the book with the new and updated content. Readers will receive an email once a new version is published!

While the book is in progress, please review it and send any feedback or error corrections at prateek@ridicurious.com

Follow @SinghPrateik

Subscribe to our mailing list
* indicates required
Email Address *

The post Infrastructure as Code with Pulumi and AWS appeared first on Ridicurious.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

AWS Lambda functions enable you to run code without worrying about what server it runs on — even if you work in a Microsoft shop.

This serverless, event-driven compute service manages back-end resources with zero administration, so developers can focus on their applications. In this tutorial, you will learn how to create an AWS Lambda function using PowerShell v6 running on .NET Core.

Read More at TechTarget.com
My new book: PowerShell Scripting Guide to Python

This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for a longer time.

“Use what you know to learn what you don’t. ” also known as Associative learning.

Book follows a comparative method to jump-start readers journey in Python, but who is the target audience? and who should read this book –

  • Any System Administrator who wants to step into Development or Programming roles, and even if you don’t want to be a developer, knowledge of another scripting language will make your skill set more robust.
  • Python Developers who want to learn PowerShell scripting and understand its ease of user and importance to manage any platform.

Python is one of the top programming languages and in fast-changing IT scenarios to DevOps and Cloud to the future – Data ScienceArtificial Intelligence (AI) and Machine Learning Python is a must know.

But this PowerShell Scripting guide to Python would be very helpful for you if you already have some knowledge of PowerShell

NOTE! This is a Leanpub “Agile-published” book. That means the book is currently unfinished and in-progress. As I continue to complete the chapters, we will re-publish the book with the new and updated content. Readers will receive an email once a new version is published!

While the book is in progress, please review it and send any feedback or error corrections at prateek@ridicurious.com

Follow @SinghPrateik

Subscribe to our mailing list
* indicates required
Email Address *

The post Step-by-Step guide to AWS Lambda with PowerShell Core appeared first on Ridicurious.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
Types of Terraform Variables

Terraform variables are a flexible and centralized way to define and save values, independent of any particular Terraform execution plan. If admins provide no values, default values can define variables in the plan. Teams can specify and override the default values through the command line.

Terraform variables fall into two categories depending on how they are used in a resource plan that an engineer wishes to execute.

  1. Input variables. Define input variables with a variable keyword, followed by a name and then, in braces, a description, default value, and type. There are different types of input variables: string, list, map and boolean.
Read More at TechTarget.com
My new book: PowerShell Scripting Guide to Python

This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for a longer time.

“Use what you know to learn what you don’t. ” also known as Associative learning.

Book follows a comparative method to jump-start readers journey in Python, but who is the target audience? and who should read this book –

  • Any System Administrator who wants to step into Development or Programming roles, and even if you don’t want to be a developer, knowledge of another scripting language will make your skill set more robust.
  • Python Developers who want to learn PowerShell scripting and understand its ease of user and importance to manage any platform.

Python is one of the top programming languages and in fast-changing IT scenarios to DevOps and Cloud to the future – Data ScienceArtificial Intelligence (AI) and Machine Learning Python is a must know.

But this PowerShell Scripting guide to Python would be very helpful for you if you already have some knowledge of PowerShell

NOTE! This is a Leanpub “Agile-published” book. That means the book is currently unfinished and in-progress. As I continue to complete the chapters, we will re-publish the book with the new and updated content. Readers will receive an email once a new version is published!

While the book is in progress, please review it and send any feedback or error corrections at prateek@ridicurious.com

Follow @SinghPrateik

Subscribe to our mailing list
* indicates required
Email Address *

The post Terraform Variables appeared first on Ridicurious.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 
How To Automate AWS S3 Static Websites Using Python

Amazon Web Services offers a very popular object storage service known as Amazon S3 (Simple Storage Service) that enables you to store data, files, images and even videos in highly available containers called ‘buckets’ which are also easy to access endpoints using any popular programming language. In a combination of AWS S3 and with other AWS services developers can build scalable and durable applications and back ends.

In this article, we will demonstrate how to automate the creation of an AWS S3 Bucket, which we will use to deploy a static website using the AWS SDK for Python also known as the Boto3 library. Please refer to my previous article here to grant programmatic access from AWS and set up the environment local computer with AWS credentials.

Let’s start with fetching details of existing S3 buckets from AWS Cloud

List existing buckets

To list all Buckets in your console using Python, simply import the boto3 library in Python and then use the ‘list_buckets()’ method of the S3 client, then iterate through all the buckets available to list the property ‘Name’ like in the following image.
import boto3
s3 = boto3.client('s3')
response = s3.list_buckets()
for bucket in response['Buckets']:
print('BucketName: {}'.format(bucket['Name']))

Read More at IpSwitch.com
My new book: PowerShell Scripting Guide to Python

This PowerShell Scripting guide to Python is designed to make readers familiar with syntax, semantics and core concepts of Python language, in an approach that readers can totally relate with the concepts of PowerShell already in their arsenal, to learn Python fast and effectively, such that it sticks with readers for longer time.

“Use what you know to learn what you don’t. ” also known as Associative learning.

Book follows a comparative method to jump start readers journey in Python, but who is the target audience? and who should read this book –

  • Any System Administrator who want to step into Development or Programming roles, and even if you don’t want to be a developer, knowledge of another scripting language will make your skill set more robust.
  • Python Developers who want to learn PowerShell scripting and understand its ease of user and importance to manage any platform.

Python is one of the top programming languages and in fast changing IT scenarios to DevOps and Cloud to the future – Data ScienceArtificial Intelligence (AI) and Machine Learning Python is a must know.

But this PowerShell Scripting guide to Python would be very helpful for you if you already have some knowledge of PowerShell

NOTE! This is a Leanpub “Agile-published” book. That means the book is currently unfinished and in-progress. As I continue to complete the chapters, we will re-publish the book with the new and updated content. Readers will receive an email once a new version is published!

While the book is in progress, please review it and send any feedback or error corrections at prateek@ridicurious.com

Follow @SinghPrateik

Subscribe to our mailing list
* indicates required
Email Address *

The post How To Automate AWS S3 Static Websites Using Python appeared first on Ridicurious.

  • Show original
  • .
  • Share
  • .
  • Favorite
  • .
  • Email
  • .
  • Add Tags 

Separate tags by commas
To access this feature, please upgrade your account.
Start your free month
Free Preview