Powershell

Clear2all Professional Blog new

How to install Firefox browser using Powershell

How to install of FireFox browser using PowerShell

Sometimes you would like to install Firefox using Powershell. Here is the script

 

Script for installation of FireFox browser

 


$SourceURL = "https://download.mozilla.org/?product=firefox-msi-latest-ssl&os=win64&lang=en-US";
$Installer = $env:TEMP + "\firefox.exe";
Invoke-WebRequest $SourceURL -OutFile $Installer;
Start-Process -FilePath $Installer -Args "/s" -Verb RunAs -Wait;
Remove-Item $Installer;

 

 

Thank you for reading!… Read the rest

Clear2all Professional Blog new

How to install chrome with Powershell?

Quick way to install chrome on windows with Powershell?

Launch the Powershell and run below script or save it as .ps1 and bypass security using this article.

Script :

$Path = $env:TEMP; $Installer = "chrome_installer.exe"; Invoke-WebRequest "http://dl.google.com/chrome/install/375.126/chrome_installer.exe" -OutFile $Path\$Installer; Start-Process -FilePath $Path\$Installer -Args "/silent /install" -Verb RunAs -Wait; Remove-Item $Path\$InstallerRead the rest

Clear2all Professional Blog new

How to Fix PowerShell Script Not Digitally Signed Error?

How to Fix PowerShell Script Not Digitally Signed Error?

When a script with a .ps1 extension then it is a PowerShell script  and when you run it, you might get the message saying “.ps1 is not digitally signed. The script will not execute on the system.”

To fix this error you have to run the command below to run Set-ExecutionPolicy and change the Execution Policy setting.

Script for fixing the error


Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

This command sets the execution policy to bypass for only the current PowerShell session though and after the window is closed, the next PowerShell … Read the rest

Clear2all Professional Blog new

Powershell Cheat Sheet for beginners

Powershell Cheat Sheet for beginners

PowerShell has become something of an ace in the hole when it comes to performing commands on Windows. For years, Windows command line fans were restricted, but PowerShell emerged as a formidable alternative in 2006.

What is PowerShell in Windows?

Microsoft created PowerShell as an interactive Command-Line Interface (CLI) and automation engine to aid in system configuration and administrative task automation.

This utility comes with its own command line and a programming language that is comparable to Perl. PowerShell was originally created to manage things on users’ computers.

Today PowerShell provides a rich environment in … Read the rest

Clear2all Professional Blog new

Can you use Linux commands in Powershell?

Today we discuss one of a few questions a lot of sysadmins and IT Admins ask?

Can you use Linux commands in Powershell?

The Windows Subsystem for Linux (WSL) was a big step forward in this regard, allowing developers to call Linux commands from Windows via wsl.exe (e.g. wsl ls). While an improvement, the experience falls short in various ways:

  1. It’s inconvenient and strange to use wsl to prefix commands.
  2. WSL login profiles with aliases and environment variables do not honour default parameters.
  3. Backslashes are sometimes misinterpreted as escape characters rather than directory separators in Windows paths supplied as arguments.
Read the rest
Clear2all Professional Blog new

Powershell Get-Eventlog Get-Process and Stop-Process commands

Get-EventLog

We use PowerShell to parse your Server’s/computers event logs using the Get-EventLog cmdlet. There are several parameters available. Use the -Log switch followed by the name of the log file to view a specific log.

For example we can use the following command to view the Application log:

Get-EventLog -Log "Application"

Few options we have with Get-Eventlog options

-Verbose
-Debug
-ErrorAction
-ErrorVariable
-WarningAction
-WarningVariable
-OutBuffer
-OutVariable

Get-WinEvent with filter for event id

PowerShell’s Get-WinEvent cmdlet is a powerful method to filter Windows event and diagnostic logs. Performance improves when a Get-WinEvent is used with filters like =FilterHashtable  with logname … Read the rest

Clear2all Professional Blog new

What is powershell execution policy?

What is powershell execution policy?

The PowerShell execution policy was created with the goal of being administrator-friendly while also being accessible to end users. The latter goal, more than the former, was a little more difficult to achieve, given that convenience is typically inversely proportionate to security.

Malicious VBS (Visual Basic Script) files disguised as useful bits of software have been sent around in emails on occasion. Unsuspecting users double-clicked the script files, falling for scams ranging from letting the script’s creator know you executed the script to giving the script’s creator entire access over your machine.

The script can … Read the rest

Clear2all Professional Blog new

How to concatenate string in powershell?

How to concatenate string in powershell?

 

1. Concatenate string Use -join

$var = -join(“Hello”, ” “, “world”);

Stores  “Hello world” to $var.

So to output, in one line:

Write-Host (-join(“Hello”, ” “, “world”))

2. Concatenate string using “-“

Write-Host “$($products.Id) – $($products.Name) – $($products.Owner)”

3. Concatenate string using indirectly with “-“

Write-Host (“{0} – {1} – {2}” -f $products.Id,$products.Name,$products.Owner )
Or just (but I don’t like it 😉 ):

Write-Host $products.Id ” – ” $products.Name ” – ” $products.Owner

 

4. Concatenate string using “+”

$string = $products.ID
$string += ” – ”
$string += $products.Name
$string += ” … Read the rest

Clear2all Professional Blog new

How to Find a string inside a string -PowerShell Substring

The PowerShell Substring : Finding a string inside a string

There are many occassions where Administrators need to figure out a way to find a certain snippet of text inside a string which is called the substring. PowerShell makes finding a substring extremely easy.

How are Strings handled in PowerShell?

A string in PowerShell is a collection of characters contained in single or double quotes. Strings examples  are  say “Adam” and “Bharat”.
Let’s imagine you have a string defined in a variable and you only need to find a portion of it. As an example, suppose you had a string … Read the rest

Clear2all Professional Blog new

How to use PowerShell Multiple-Line Comments

How to use PowerShell Multiple-Line Comments?

Use Windows PowerShell multiple line comments in your script or from the console. It is good for debugging for later using it multiple times reuse in other scripts.

Syntax:

Begin the comment with the <# tag, and end the comment with the #> tag:

<# this is a comment on several different lines #>

 

When we enter # on each line or the “#” and “#>” to surround each code block in a remark block

Now PowerShell Studio 2014 makes comments easier.

  1. To individually comment out each line (#)
  2. select one or more
Read the rest