Chirag Nagrekar has Published 468 Answers

How to set the local user account settings using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 12:51:03

To set the local user account settings related to the account or the password expiration, we can use the Set-LocalUser command.The below command will change the local user Testuser account and password set to never expire.Set-LocalUser -Name Testuser -AccountNeverExpires -PasswordNeverExpires $true -VerboseThe below command will set the account expiry, Set-LocalUser ... Read More

How to find the locked local user accounts using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 12:48:43

To get the locked user accounts on the local or the remote machines using PowerShell, we can use the wmi method.PS C:\> gwmi win32_useraccount | where{$_.Lockout -eq $true}You can also use the CIM instance method alternatively.PS C:\> Get-CimInstance Win32_Useraccount | where{$_.Lockout -eq $true}To get the locked local user accounts on ... Read More

How to validate the path with the PowerShell function parameter?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 12:42:17

To validate the file or folder path inside the PowerShell function parameter, we need to use the ValidateScript command. Generally, we write the script as below to validate the path.function Validate-Path{    param(       [parameter(Mandatory)]       [String]$Path    )    if(Test-Path $Path) {Write-Output "Path is valid"} ... Read More

How to copy files of the specific extension using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 12:38:39

To copy the files using the specific files extension using PowerShell, we can use the Copy-Item command.The below command will copy only the .ps1 files from the source to the destination.For example, PS C:\> Copy-Item -Path C:\Temp -Recurse -Filter *.ps1 -Destination C:\Temp1\ -VerboseIf the C:\Temp1 doesn't exist, it will create ... Read More

How to get the disabled local user accounts using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 12:37:12

To get the disabled local user accounts using PowerShell on the local and the remote system, we can use the WMI or the CIM instance method with the Win32_UserAccount class and the Disabled property to filter the result.PS C:\> gwmi win32_useraccount | where{$_.Disabled -eq $true}You can filter out the properties ... Read More

How to add the user to the local Administrators group using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 12:20:48

To add the AD user or the local user to the local Administrators group using PowerShell, we need to use the Add-LocalGroupMember command.To add the local user to the local Administrators group, Add-LocalGroupMember -Group Administrators -Member TestUser -VerboseThe above command will add TestUser to the local Administrators group. You can ... Read More

How to create a new local user in windows using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 12:20:05

To create a new local user in the Windows operating system using PowerShell, we can use the New-LocalUser cmdlet. The below command will create the TestUser with no password.New-LocalUser -Name TestUser -NoPasswordOutputName Enabled Description ---- ------- ----------- TestUser TrueTestUser account has been enabled here. To provide the password for the ... Read More

How to install MSI file using batch file in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 12:17:21

Let say we have one MSI file and we need to install the MSI file on the remote computers using PowerShell but that MSI file should be deployed with the Batch file and should be executed using PowerShell.In this example, we have a 7-zip MSI file and batch file we ... Read More

How to retrieve the Azure VM RAM and CPU size using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 12:08:03

Azure VM RAM and CPU size depend on the hardware profile chosen for the VM. In this example, we will retrieve VM (TestMachine2k16) hardware profile and then we can find how much RAM or CPU is allocated to it.To get the Size of the Azure VM, PS C:\> $azvm = ... Read More

How to retrieve the Azure VM Subscription Name using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 17-May-2021 12:07:25

Once you are connected to the Azure Account, there are possibilities that the Get-AzVM will display the VMs from all the Azure Subscriptions.To find the specific Azure VM Subscription name, we will first retrieve the details of the VM using the Get-AzVM and it has an ID property that contains ... Read More

Previous 1 ... 6 7 8 9 10 11 12 ... 47 Next
Advertisements