
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 462 Articles for PowerShell

4K+ Views
Storage context is helpful when you are working with the Storage accounts in the PowerShell session. It is like authenticating for Azure storage. Generally, we use the Azure storage account key and the connection string to create the Azure storage context.To create a new storage context, we need to use the New-AzStorageContext command but to use this command we need a storage account key or the connection string.We will use here Storage account key. We have the resource group “Az204” and the Storage account name “az204storage05june” which are stored in a variable.$rg = "az204" $storageaccount = "az204storage05june"To get the storage account ... Read More

5K+ Views
To use the Azure Rest API using PowerShell, we first need to connect to the Azure cloud account using the Connect-AzAccount. Once you are connected to the Azure Account, you can use the below authorization header (same has been provided on the MS website) which contains a bearer token to authenticate the rest API.$azContext = Get-AzContext $azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRm ProfileProvider]::Instance.Profile $profileClient = New-Object - TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient - ArgumentList ($azProfile) $token = $profileClient.AcquireAccessToken($azContext.Subscription.TenantId) $authHeader = @{ 'Content-Type'='application/json' 'Authorization'='Bearer ' + $token.AccessToken }Once you have the Authorization header available, you can use it for authentication. Now let assume we need ... Read More

58K+ Views
As of now, there is no built-in command like CSV (Export-CSV) to export output to the excel file but we can use the Out-File command to export data to excel or any other file format.Let’s use Out-File to export the output of the Get-Processes command to an excel file.Get-Process | Out-File C:\Temp\processes.xlsThe above command will get all the running processes on the local system to the excel file. Let’s check the output of the excel file. You can see that the output is not in the proper excel format.One other way is to install the ImportExcel module for excel. It ... Read More

15K+ Views
When you run Invoke-WebRequest or Invoke-RestMethod command, sometimes you get the error “The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.” because there could be a certificate issue or the required windows version doesn’t support the TLS or SSL version. You can use the below command to bypass this error.[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}Or you can use the below code to resolve this error.Exampleadd-type @" using System.Net; using System.Security.Cryptography.X509Certificates; public class TrustAllCertsPolicy : ICertificatePolicy { public bool CheckValidationResult( ServicePoint srvPoint, X509Certificate certificate, WebRequest request, ... Read More

241 Views
To disable the Azure VM accelerated settings using PowerShell, we need to disable the EnableAcceleratedNetworking property on the NIC attached to the VM.$vm = Get-AzVM -Name TestVM $nicname = (($vm.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1] $nicsetting = Get-AzNetworkInterface -ResourceGroupName $vm.ResourceGroupName - Name $nicname $nicsetting.EnableAcceleratedNetworking = $falseIn the above example, we are setting AN settings on the Azure VM “TestVM”. To set the AN setting on the particular subscription, use the below command. Make sure that you are connected to the proper subscription using the Set-AzContext command.Get-AzVM | Select Name, ResourceGroupName, ` @{N='Accelerated Netoworking'; E={ $nic = (($_.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1] $nicsetting = ... Read More

226 Views
To enable the Azure VM accelerated settings using PowerShell, we need to enable the EnableAcceleratedNetworking property on the NIC attached to the VM.$vm = Get-AzVM -Name TestVM $nicname = (($vm.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1] $nicsetting = Get-AzNetworkInterface -ResourceGroupName $vm.ResourceGroupName - Name $nicname $nicsetting.EnableAcceleratedNetworking = $trueIn the above example, we are setting AN settings on the Azure VM “TestVM”. To set the AN setting on the particular subscription, use the below command. Make sure that you are connected to the proper subscription using the Set-AzContext command.Get-AzVM | Select Name, ResourceGroupName, ` @{N='Accelerated Netoworking'; E={ $nic = (($_.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1] $nicsetting ... Read More

631 Views
From the Azure Portal, we can find the Accelerated Networking (AN) status from the networking blade.To get the AN settings on the VM, we need to first retrieve the NIC information because it is set on it. We have the VM named ‘TestVM’ and we will retrieve its NIC information.PS C:\> $vm = Get-AzVM -Name TestVMTo get the NIC associated with the VM, $nicname = (($vm.NetworkProfile.NetworkInterfaces.id).Split('/'))[-1]We need to retrieve the NIC settings to get the AN setting.$nicsetting = Get-AzNetworkInterface -ResourceGroupName $vm.ResourceGroupName - Name $nicnameTo get the AN settings, use the EnableAcceleratedNetworking property.$nicsetting.EnableAcceleratedNetworkingIf you want to retrieve the AN settings on ... Read More

936 Views
Basic authentication is the insecure authentication for windows. Before enabling it make sure you comply with your organization policies. To enable the basic authentication for the windows servers using PowerShell, we can use the below command.PS C:\> Set-Item -Path "WSMan:\localhost\Service\Auth\Basic" -Value $true -VerboseTo enable the basic authentication for the remote windows servers using PowerShell, use the below command.Invoke-Command -ComputerName TestMahchine1, TestMachine2 - ScriptBlock { Set-Item -Path "WSMan:\localhost\Service\Auth\Basic" -Value $true -Verbose }

432 Views
Basic authentication is the insecure authentication for the windows. To disable the basic authentication on the windows server using PowerShell,PS C:\> Set-Item -Path "WSMan:\localhost\Service\Auth\Basic" -Value $false -VerboseTo disable the basic authentication on the remote windows servers using PowerShell, use the below command,Invoke-Command -ComputerName TestMahchine1, TestMachine2 - ScriptBlock { Set-Item -Path "WSMan:\localhost\Service\Auth\Basic" -Value $false -Verbose }

871 Views
To disable the credssp on the local computer using PowerShell, use the below command.PS C:\> Disable-WSManCredSSP -Role Server -VerboseYou can check if the credssp is disabled, using the below command.PS C:\> Get-ChildItem WSMan:\localhost\Service\Auth | Where-Object {$_.Name -eq"CredSSP"} | Select Name, Value Name Value ---- ----- CredSSP falseTo disable the credssp authentication on the remote computers using PowerShell,Invoke-Command -ComputerName TestMahchine1, TestMachine2 - ScriptBlock { Disable-WSManCredSSP -Role Server }