#Linux guy who want to learn powershell for azure and Windows Server need tips

22 messages · Page 1 of 1 (latest)

radiant laurel
#

Hello, my name is Adrien. Currently, I am in an internship and I manage mostly Linux servers. The company wants to migrate some servers to the Azure cloud and use Windows Server for user administration. I think it's time to learn PowerShell, but I am a beginner in Windows. I know the basics of AD and a few cmdlets, but nothing more. Do you have any tips on how to be efficient with this language for automation? I have coded in Java or Bash before and already did a lot of script in bash , for example

crude bluff
#

i think you have the bonus of already being familiar with cli/scripting. I have nothing specific for you unfortunately but someone else will. Check out #resources though!

rare latch
#

Having the knowledge you have is a head start, I would always suggest just start with learning syntax and how the pipeline works, playing around with processes or services on a test system. Then learning how to get help on the fly: get-member, get-command, get-help or "help" etc..

Once ready, set a task for yourself to complete, for something advanced: try setup a test server and promote into a DC for a new AD forest & domain. Install server core if you feel you might cheat!

Then try populate it with characters out of the starwars api or something like that

If that is a little too far in the deep end, try just working with an api and changing the properties on objects, try exporting data into CSVs, try working with files, shares, registry etc.. I found doing some mundane hello world task is pointless unless scripting, shells and all the sorts is totally alien to you then yes, start there! But if not, start with something relevant to the reason you bothered starting in the first place

Then build out with whatever you wish to learn. Go nuts

sudden wave
#

For what it is worth, I'd recommend going with Oracle Cloud/Powershell combo over Azure/Windows combo. Oracle Cloud has a PowerShell module that allows one to manage the whole cloud infrastructure. https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/powershell.htm

I've been managing my VM instance in OCI for over 2 years now at zero hosting costs using just Linux/PowerShell combo.

Here is a blog on how to do a boot volume backup using the OCI module. https://cadayton.onrender.com/blog/PSOciBootBackup.html

radiant laurel
radiant laurel
rare latch
# radiant laurel Yeah currently i'm creating things with powershell server status , active direct...

Thats all there is too it!! work with these sort of things then you can build on that as you get better with practise. For files try making a scrip that generates and folder for <x> year that you can input then it makes that year with each month as sub folders?

Or, one i made recently in fact... Try making a scrip that can mount a file share as an "X" drive then backup a source folders data that has been changed/created within the last 2 days or something and delete anything older in the source.

For registry, you need the knowledge of windows really to do anything major but one i did recently was removing app data (non admin) software installs for all users on a PC without calling any installers. I enter a non ambiguous app name and boom... Gone! This was because Opera browser decided a --silent switch was not needed to uninstall as well as admin rights are not needed to install it.... yeah. Or you can play around with just simply changing windows settings via the registry in PowerShell, try changing the mundane OOB stuff you'd do for a new PC (all automated imaging/deployment tools aside here)

radiant laurel
unkempt elbow
#

I would say learning how to write a cmdlet/function that supports pipeline input(process block), it helps to understand usages of cmdlets pipe. Item cmdlets are really good start point to practice pipeline, you can always manipulate items within pure pipeline, really fluent, try it out!CommonParameters for cmdlet are also interesting, it allows you to do value-based error handling which is a better practice in pwsh. With these knowledge you can write more decent statement with less variable declared.

radiant laurel
unkempt elbow
radiant laurel
crude bluff
#

or you can do something like

try {
   $RootOU = Get-ADOrganizationalUnit -Identity $RootDN -ErrorAction Stop
}
catch {
  Write-Warning "The OU '$Ou' does not exist under this Domain Controller"
}
#

just depends on your use case and preferences. just play around with different methods

agile dew
#

there is plenty of pwsh in the Azure world. no need for oracle cloud.

i would start with converting one-liners or scripts you wrote in bash. Then I might try my hand at converting the Java to pwsh. I might try it first on `*nix host. This is about as practical and fast as I can think assuming you learn better with goals and clear beginning and end. loose goals are the death of learning and starting with a book can hurt that learning. advent of code is relevant now too.

#

they key is the object pipeline over text and reworking your mind around it.

#

dropping regex mentality or spliting on spaces using cut, awk. Many of the tools in *nix are mostly useless with objects.

#

another key is thinking in terms of APIs instead of text or files

radiant laurel
agile dew
radiant laurel