• 100 percent on the difficulty in filtering properties. Honestly, that makes CLI a dealbreaker for me in many contexts. Thanks for reading! -Tim

  • I think it’s great that both are available. For someone coming from a Linux background, the AZ CLI is really familiar and consistent with what they’re used to. For me, who has a lot of PowerShell experience, I’m much happier with AZ PowerShell. I’m so used to having my outputs be objects, it’s always a frustration to get the output from AZ CLI.

    At least I found “-o table” for AZ CLI, which helps a lot. But filtering properties, I have to look up the reference on how to do it every time.

  • All modern shells and command lines offer a prompt that provides the user with essential information about his context. By default, however, PowerShell displays only the current directory. Since its appearance is determined by a function, you can change the PowerShell prompt easily.

  • Sponsor posted an update in the group Group logo of PowerShellPowerShell 2 days, 10 hours ago

    Webinar: Automate your Azure administration - it's easy!
    Would you like to simplify and speed up the management of your Azure services? PowerShell offers a lot of possibilities to achieve that.
    In this webinar, we will show you how you can use the Azure Az PowerShell module and ScriptRunner to easily and securely automate and delegate many recurring tasks (e.g. managing virtual machines and Resource Groups).
    The webinar is aimed at administrators, solution architects and IT team leaders.
    Register for free!
  • Hello Surender Kumar.
    I was wonder if you can give me an advise or point to the correct search material.
    I can not seem to be able to figure out how to get TMP to trigger Pin request on boot.

    All machines in our company are part of AD.
    I use NinjaRMM to execute power shell scripts remotely.
    Checkpoint Endpoint Security to trigger BitLocker encryption process on deployment.

    Unfortunately, I was recently tasked with helping my boss to let go of one of our employees next week.
    The issue I got stuck with is he is a developer and remote. The only way I found that I can/should lock him out of the machine is by sending PowerShell script to enable Pin request on boot. Then just restart the machine.
    I am not that good with PowerShell and BitLocker TPM process.
    I can not seem to figure out how to trigger it.

    Setting the Pin by open

    Any help would be greatly appreciated.
    Thank you.

  • To be honest, I don’t remember when I was doing this at all lol.

    I will have to go revisit that as soon as I can. 🙂

    David F.

  • Hi David! Do you have .NET SDK installed? If not, that might be your problem. .NET SDK has a “pack” command which PowerShellGet uses to create packages.

  • The code i wrote is a function which means you have to load it into memory first or add it to your profile so it is autoloaded when you start your powershell prompt.

    to load the function:

    [powershell]. (path to file)backup-grouppolicy.ps1 [/powershell]
    Notice the extra dot in the front of the line. You can also lookup dot-sourcing for a full explainer.

    then the cmdlet Backup-GroupPolicy will be avilable to use like any other cmdlet.

  • I am trying to use this script, but it’s just doing “nothing” when I run it.

    PS C:Scripts> .Backup-GroupPolicy -Path “C:ScriptsGPO_BUs” -Server DC
    PS C:Scripts>

    Any insight on this?

  • But there’s a huge difference between professional programmers and scripting admins. Script writers aren’t always looking at idempotency. And as one of the scripting admins.. if I’m doing something that starts deleting things, I do put in lots of checks, and force error checking.

    But, bad script design is bad script design 🙂

    David F.

  • Good article, nicely written. Another similarity is that from azure portal, one can launch a cloud shell in either of these two environments.

  • There is a reason that proper programming languages do not have the concept of non-terminating errors: it leads to unforeseeable results too often. Because errors tend to occur where nobody is expecting them.

    During 20 years of development and administration, I have met only about a handful of edge-cases where I actually used an empty catch-block (and commented the reason).
    But I have seen a gazillion scripts ignoring errors and causing real damage afterwards. E.g. one of those scripts had the task of cleaning up a directory. The dev ignored errors, since the script could encounter files in use and should just leave them. But one time it failed in determining the path itself and continued with $null as a value. The developer did not expect issues there. But now, his script deleted everything in the default-path, which was the user’s home-folder.

    A very good practice in software development (aside from gaming) is to fail as early as possible. This applies to script development as well.

    And if a developer does really have one of the edge-cases at his hands, where he wants to continue, he can always decide to do so by using an empty catch-block. But this should only be done after careful consideration and not as default-behaviour.

    Ignoring errors by default was just a stupid decision by MS.

  • I would respectively disagree – it’s always a matter of perspective and usage. Depending on the script, setting ErrorActionPreference to Stop can absolutely cause all kinds of noise, bloated problems.

    However, for troubleshooting purposes, sometimes it does help to set EA to Stop.. it’s very circumstantial.

    David F.

  • In your work in Microsoft Azure, should you focus your energies on Azure PowerShell, Azure CLI, or both? This lesson presents a comprehensive comparison of the two primary scripting languages in the Azure cloud.

  • That is really great stuff! I’ve always missed $string.right(n) $string.left(n) -This just about makes up for it

  • Most programming languages provide string functions that can be used to selectively truncate leading or trailing characters. String objects in PowerShell have three such trim() methods that remove not only spaces but also any characters at the beginning and end.

  • You should always set the $ErrorActionPreference to “Stop”.

    The distinction between non-terminating and terminating errors is the source of very many errors on itself. Because in almost all cases, the script is in an unexpected state after an error: the developer just does not remember to check for all possible errors. And letting software run in a state that the developer did not expect is always a bad idea.

    I have seen this happen very often: some batch encounters an error and just keeps doing “something”. The work to clean up this mess is almost always much worse than having a clear error in the first place.

  • Very handy to have – they are increasing the amount of required reporting at work, so this could be a real time-saver. Thanks! –S.

  • Hi

    Can anyone provide me with a script to move my files from my NAS File Server Storage Location directly to my External USB connected drive without interference.

    Regards
    Mario

  • Load More
© 4sysops 2006 - 2023

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account