Posts

Showing posts from March, 2018

PowerShell - List local users and groups

When you have a bunch of servers to manage and those servers are joined to an Active Directory Domain, it is really easy to query information from a single location, but when you are not using AD things get a little more complicated. It is a typical request to get the user list from all your users and the groups they belong to. If you are using AD, try installing the Power Shell Active Directory Module ( See 4Sysops article ). But if all your servers are not joined to a domain you will need to query the local users and groups so the Active Directory module is useless. Luckily, we can use the " Active Directory Service Interfaces " a.k.a [ADSI] . The script to query the users and groups and export a list ready to imported into a spreadsheet is really simple: $computerName = $env:COMPUTERNAME.Trim("`t|`n|`r") $computer = [ADSI]"WinNT://$computerName" $computer.psbase.children | where { $_.psbase.schemaClassName -eq 'group' } | foreach {     $g...

set-AzureRmVMCustomScriptExtension - Failed

Image
So, you are working with azure powershell and customs scrips and are facing with this error: You already played with storage account keys, verified that the file is accessible using a web browser, tried loading the script using the azure portal directly and nothing seems to work. Well, the next thing you need to do is take a look at the logs in the virtual machine. In theory every machine deployed in Azure contains a VM agent that is in charge of the interaction between azure and the VM. There are 2 locations no need to take a look at when debugging problems with Azure and custom scripts.  C:\WindowsAzure and C:\Packages . In order to get more data about the error, log into the VM you need to install the custom script and open the file:  C:\WindowsAzure\Logs\Plugins\Microsoft.Compute.CustomScriptExtension\1.9\CustomScriptHandler.log In that location you will get additional information about the problem. In my case I found this: [5400+00000001] [03/20/2018 16:02:43...