PowerShell day 5

PowerShell day 5

Day #5 of #powershelltopincinaweekatluncheschallenge

Hey guys???? its another day of our PowerShell lesson ,today we will be talking about PowerShell scripts and how to manage cloud with PowerShell.

PowerShell scripts

As we all know Visual Code is one of the best programs used to run PowerShell. PowerShell is a set of codes that performs a specific task. It is also a PowerShell file that contains PowerShell logic. You should attempt writing your first script. Just think about processes you perform often at work that requests a lot of manual steps.

Steps to create a script in PowerShell (Windows 10)

  • Create a script with VS Code

Visual Studio Code (VS Code) is a free and extensible cross-platform code editor that allows you to edit virtually any programming language. And when adding the PowerShell extension, you get an interactive scripting editing experience that even includes IntelliSense (code-completion) support. The PowerShell ISE application will continue to be available, but the Visual Studio Code with the PowerShell extension is meant to be the new default experience. Also, consider that the legacy experience won't get any new features and doesn't support PowerShell 7 or higher releases.

  • Install Visual Studio Code

To install Visual Basic Code on Windows 10, use these steps:

1. Open the Visual Studio code editor

2. Click the?Windows?button to download the installer.

3. Double-click the installer to begin the installation process.

4. Confirm the agreement term.

5.Click the?Next?button.

6.Confirm additional tasks as necessary.

7.Click the?Next?button again.

8.Click the?Trust Workspace & Install?button. After you complete the steps, you can start writing PowerShell scripts using Visual Studio Code on Windows 10.

Creating and saving PowerShell scripts: Creating a PowerShell script is just saving your PowerShell commands with the math.ps1 file. Go ahead and copy the simple code and save it as a math.ps1.

PowerShell execution policy

Depending on the configuration of your device and environment you may not be able to run PowerShell scripts. There are execution policies concerning PowerShell that will need to adjust.

  • Restricted?— Stops any script from running.
  • RemoteSigned?— Runs scripts created on the device. However, scripts created on another computer won’t run unless they include a signature of a trusted publisher.
  • AllSigned?— All the scripts will run as long as they’ve been signed by a trusted publisher.
  • Unrestricted?— Runs any script without any restrictions.

To determine the current execution policy run the following cmdlet in diagram 2 and 3.

Script Scope

Are you aware that when you run a script by specifying the ps1 file ,that script does not run in the scope of the current session. you will not have access to the variables and information in your current session. You can see this in action for yourself. Open a PowerShell window and run the?math.ps1?script from above. After it runs, try typing?$total?in your PowerShell session. It will not return anything. This is because?math.ps1?was run under the scope of a different PowerShell session. Once the script completed, so did that session. I guess you want to write your first script. Just break the objective into manageable chunks.

  • Supports logging
  • Checks desired drive for free space
  • Sends Telegram notification
  • Lets user specify drive
  • Supports both windows and Linux

Manage cloud with PowerShell

Cloud computing is the on-demand availability of computer system resources especially data storage (cloud storage) and computing power, without direct active management by the user. Cloud computing gives you access to storage ,files, software and servers through internet-connected devices ,computer, smart phones ,tablets and wearable. Cloud technology has experiences explosive growth over the last several years. Since cloud was introduces rapid provisioning ,cost efficiency ,enhanced security and performance .

Did you know that Amazon Web Services(AWS) is the largest cloud provider .AWS tool is essentially just a module or collection of modules that enable your existing PowerShell to manage the Amazon Web Service Cloud.

Managing AWS cloud with PowerShell

With your PowerShell session authenticated to your AWS account you might be thinking, now what? The answer is the possibilities are nearly limitless. Using PowerShell the entire power of the AWS cloud is at your fingertips.

  • Create a virtual server and establish access
  • Create a fleet of 500 servers pre-configured to your needed specification
  • Retrieve billing information
  • Create monitors and alarms
  • Create serverless solutions

PowerShell Azure

  • It contains PowerShell cmdlets for developers and administrators to develop, deploy, administer, and manage Microsoft Azure resources. The Azure PowerShell module is preinstalled in Azure Cloud Shell. Azure module – this is a replacement for AzureRM and AzureRM. Netcore and is now the primary PowerShell module for Azure. It supports PowerShell 5.1 and 6.1+.
  • Azure RM module – officially maintained through December 2020 but will no longer receive new cmdlets or features.

Azure PowerShell collects telemetry data by default. Microsoft aggregates collected data to identify patterns of usage to identify common issues and to improve the experience of Azure PowerShell. Microsoft Azure PowerShell does not collect any private or personal data. For example, the usage data helps identify issues such as cmdlets with low success and helps prioritize our work. While we appreciate the insights this data provides, we also understand that not everyone wants to send usage data.

"Trust yourself that you can do it and get it " - Baz Luhrmann

Alexandra Boateng

Educ8Africa Ghana

Brian Y. Woyome

Newman Mortey

#powershelltopicinaweekatluncheschallenge

#educ8africa ghana

#eccouncil

#cybersecurity

#certifiednetworkdefender

#Day5

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
No alt text provided for this image


Gladys Ivy Mensah

Information Technology Management

2 年

Irène Kinsy Thanks

回复
Tutu Afakye

Passionate Cybersecurity Enthusiast | Crafting a Secure Digital Future

2 年

????

回复

要查看或添加评论,请登录

Gladys Ivy Mensah的更多文章

  • #My90DaysNetworkDefenseDiary

    #My90DaysNetworkDefenseDiary

    Day #1 of #My90DaysNetworkDefenseDiary We haven't spoken in a very long time; I briefly disappeared ??. I'm thrilled to…

  • User Identities

    User Identities

    #useridentities What Is User Identity? It is an entity used to identify a user on a website, in software, on a system…

  • Basic Networking

    Basic Networking

    Hi guys #120HoursofBasicNetworking An IP address is a unique address that identifies a device on the internet or a…

    1 条评论
  • Day 1

    Day 1

    Day #1 of #120hoursofbasicnetworking Hey guys we are starting our basic networking journey. First of all a network is a…

  • PowerShell Modules

    PowerShell Modules

    #powershelltopincinaweekatlunchesextensionchallenge PowerShell module A PowerShell module is a .psm1 file (a script…

  • PowerShell Remoting

    PowerShell Remoting

    Day #6 of #powershellweekchallenge Remoting Did you know that remoting is a technology that allows a program to…

    2 条评论
  • Day 6

    Day 6

    Day #6 of #powershelltopicinaweekchallenge.Hey guys its day 6 of our PowerShell discussion.

  • PowerShell Day 4

    PowerShell Day 4

    Day #4 of #powershelltopicinaweelatluncheschallenge Hi guys ,???? as we all know PowerShell created by Jeffery Snover…

  • Day 3

    Day 3

    #powershelltopicinaweekatluncheschallenge #educ8africa ghana #eccouncil #cybersecurity #certifiednetworkdefender #Day3…

  • Day 2

    Day 2

    #powershelltopicinaweekatluncheschallenge #educ8africa ghana #eccouncil #cybersecurity #certifiednetworkdefender #Day2…

    1 条评论

社区洞察

其他会员也浏览了