The PowerShell scripting language has been called “automation glue” more times than I can count. It’s a fitting description if you’ve worked with it a lot. You may get the automation part of the title right away if you’ve merely heard of PowerShell and what it can do but the “glue” part may leave you wondering why. PowerShell was born at [...]
The post Building PowerShell Scripts to Tie Disparate Products Together appeared first on Adam, the Automator.
Cached credentials make users’ lives easier, but they can be a security issue in Windows if a device falls into the wrong hands. IT can manage them on a large scale with PowerShell. Users like cached credentials because they are convenient and keep them from having to type in their login information every time they access their devices. For IT, [...]
The post Clear Cached Credentials With the cmdkey and PowerShell appeared first on Adam, the Automator.
Tonight I was invited to speak at the EIC Inspiration event, located in Groningen. It was my first time attending, and as a result, speaking at this event. If you living in the neighborhood or if you are interested in the events they host have a look over here: IEC Inspiration There was a photographer […]
Don’t let your entire workflow be hung up because one of the scripts is stuck on some task. There’s a way around that! Have you ever written an excellent PowerShell script only to find that it just hangs on some task without any indication why? It’s especially frustrating if the script is being kicked off by an unattended process. The [...]
The post Creating a Timeout Feature in Your PowerShell Scripts appeared first on Adam, the Automator.
When trying to enumerate all profiles, you need a script that can account for a variety of scenarios. An everyday task that many admins must perform when working with both Windows server and client operating systems is listing all user profiles. A user’s profile is the usual place that every installed application, as well as Windows itself, places files and [...]
The post How to Accurately Enumerate Windows User Profiles With PowerShell appeared first on Adam, the Automator.
The Pester people don’t really recommend this, but, I find it can be really helpful sometimes. What I’m talking about is dynamically creating assertions inside of a Pester test using PowerShell. While I think you should striveRead More...
Keeping tabs on what a script is doing is critical for monitoring and debugging. Monitoring a script can be done in many different ways, but it is usually dependent on how it’s being executed. If a script is invoked interactively, meaning directly from the console using techniques such as Write-Verbose, Write-Information or Write-Host, it is useful because each command can display messages on the console [.
It had already been well over a year since the first iteration of the DuPSUG Basics day, but yesterday we finally had the opportunity to host our second day of basic PowerShell training. This time we were hosted at the Sogeti office in Vianen. BEGIN END SPEAKER TITLE 09:15 10:30 Mark van de Waarsenburg Powershell […]
System administrators and developers must come to the table and learn each other’s jobs, or they may find themselves without a job. Are you manually creating new virtual machines? Are you going into the Active Directory Users and Computers tool and creating, modifying or resetting passwords? If so, you may be looking for a new job in 5 years. In [...]
The post Learn to Code or Else: An Information Technology Professional’s Guide appeared first on Adam, the Automator.
Table of Contents
Table of Contents
What is InvokeBuild?
PowerShell Module Development Workflow
Creating The InvokeBuild Script
Creating the Install Dependencies InvokeBuild Task
Adding Linting with PSScriptAnalyzer
Testing the Code with Pester
Updating the Module Manifest
Generating an Artifact
What is InvokeBuild?
Invoke-Build is a build automation tool written in PowerShell.
Last week I had the pleasure of presenting for the Austin PowerShell UG, this is a group run by Ricc Babbitt. During this session I presented the following topic: Reach the next level with PowerShell During this presentation I walked the audience through the process of developing a short script to gather information from a system. […]
Based on the news today, I thought I would share a couple of PowerShell code snippets to detect the presence of and silently uninstall CCleaner. You can detect the presence of CCleaner along with the version of it you have installed via the registry. You can use a similar command to run its uninstaller silently if it’s detected. Give it a couple of minutes and then run the first command again to verify it has been removed.
By purposefully building PowerShell functions for the purpose of using the Pipeline, our functions can interact with each other in an easy to understand manner. PowerShell allows you to create functions that have a number of different purposes. Functions allow the scripter to combine like-code into building blocks which can then be used to build even larger functions or scripts. [...]
The post Here’s How to Create PowerShell Functions for the Pipeline appeared first on Adam, the Automator.
Are you constantly trying to find that script you know you wrote months ago but can’t find it? You need to build modules. Do you have a bunch of PowerShell scripts in a folder somewhere called Scripts? Are a bunch of those scripts all related like SQL, Active Directory, some private business process, etc.? Are you constantly trying to find [...]
The post Find Out How to Build Your First PowerShell Module appeared first on Adam, the Automator.
Когда мы хотим получить информацию о членстве в группах определенного пользователя или компьютера, мы можем воспользоваться командлетами Get-ADPrincipalGroupMembership или Get-ADAccountAuthorizationGroup. Первый из них выведет информацию обо всех группах, в которые объект входит непосредственно. Результат выполнения второго командлета будет содержать все группы, в которые объект входит как явно, так и через другие группы.
Группы Active Directory используются для множества разных целей, будь то фильтрация групповой политики или назначение определенных привилегий пользователям. Достаточно гибкая структура позволяет разграничивать объекты пользователей и компьютеров наиболее удобным для нас образом. Но в то же время это приводит к образованию иерархии групп, состоящей из нескольких уровней (что, в общем то, нормально)
According to the help content, Measure-Object ‘calculates the numeric properties of objects, and the characters, words, and lines in string objects, such as files of text.’ This is a vague description of what this command can do, so let’s dive into that and go over a few contexts where using the Measure-Object command might make sense. Peter Drucker, a legendary [...]
The post Measure Objects in PowerShell with the Measure-Object cmdlet appeared first on Adam, the Automator.
The Restart-Computer PowerShell cmdlet lets you reboot multiple computers in the console or in your scripts. Learn about all the options in this article. Rebooting a Windows computer is easy, right? We click the Start button and click Restart, and it just does it. This is fine for your computer at home, but what about doing this at work where [...]
The post Reboot with the Restart-Computer PowerShell cmdlet appeared first on Adam, the Automator.
I recently had a need to perform some security auditing on an environment that still has some servers running PowerShell version 2 (PowerShell version 2 is deprecated). One of the things I needed to determine was whether or not the Windows firewall was enabled on each of the servers in the environment. Luckily, all of the servers at least had PowerShell remoting enabled. The PowerShell function shown in the previous code example is a wrapper for the Netsh.
I’m always looking for ways to help teach PowerShell and the other day I thought why not have PowerShell teach you itself? I have created a PowerShell script that dynamically generates a quiz on cmdlets and functions installed on your computer. In short the quiz question shows you a command synopsis and then presents a […]
With Windows 10, you can install Bash on Windows. Cool, right? Having Bash on Windows goes a long way towards making Windows a more developer-friendly environment and opens a ton of doors. The one I’m goingRead More...
Вслед предыдущей статье, где мы рассматривали способы фильтрации с использованием значений флагов в атрибутах, представленных в виде битовых масок, давайте поговорим о подходах к изменению значений таких атрибутов. В атрибутах такого типа каждый бит является отдельным флагом и имеет свое собственное значение. Примерами таких атрибутов являются UserAccountControl для объектов пользователей и компью
As I have been speaking at a number of events recently I also have been updating my GitHub Events repository. Usually I include a markdown file with a short description, my demos and my slides. I had been uploading my files as .pptx and I noticed that the repository edged over 100 MB. This prompted […]
What is LAPS and why I need it In windows domain based environments accounts with domain admin rights should be protected by all means. We all know that those accounts have the greatest privileges in the domain. There are other accounts that should be kept secure as well. Sean Metcalf has a great article about … Continue reading LAPS deployment
Как мы знаем, многие атрибуты объектов Active Directory представлены в виде битовых масок. Например, такие как UserAccountControl для объектов пользователя или компьютера или GroupType для объекта группы. И хотя командлеты модуля ActiveDirectory представляют эти значения в виде отдельных атрибутов, скрывая от пользователя их истинную природу, иногда нам все-таки приходится работать с ними напрямую.
В продолжение предыдущей темы о конвертации значений даты и времени, в этот раз поговорим об объектах WMI. Для получения экземпляров объектов WMI нам доступны несколько способов. Один из них — это использование командлетов модуля CIMCmdlets. Например, так: Теперь, если мы посмотрим на значение свойства LastBootUpTime, мы увидим, что оно вполне себе похоже на объект DateTime. […]
I recently received a message on Skype from a friend I had not talked to for a while, I was happy to see it was spam. Not because it was spam, but because it was using an encoded Url. After taking a quick look at the structure I thought, this is definitely something I can […]
My top preference for data munging and harvesting from The Web is Internet Explorer, Yes, Internet Explorer! 🙂 because I can create an InternetExplorer.Application object and access the HTML DOM to scrape web data as and when required. The problem arises when all information on the web page is not populated by default when the page loads,… Read More Scrolling Internet Explorer with Pow
Setting up a scheduled task or job on individual servers to cleanup log and temp files just doesn’t scale very well because you have scheduled tasks or jobs setup on lots of individual servers that need to be maintained. Today it’s this server and tomorrow it’s two or three more. It’s much easier to setup one scheduled task or job on a server that’s designed for management to remotely cleanup the desired files on all of your servers.
Скажем сразу — все, что здесь описано касается также и остальных атрибутов, содержащих значение даты и времени. Тем не менее в этой статье мы будем говорить об атрибуте pwdLastSet, а применить описанные подходы к другим атрибутам вы сможете и сами. Когда для запросов к Active Directory мы используем командлеты одноименного модуля, то результаты их выполнения […]
В предыдущей статье мы говорили о преобразовании SID из массива байтов в строчный формат. Почему бы нам не написать функцию для обратного преобразования. Назовем ее ConvertFrom-sthSID. Начнем с определения параметра. В качестве его имени мы выберем SID, его использование будет обязательным, и, так же как и в предыдущем случае, мы не будем против если пользователи […]
Работать с Active Directory из PowerShell гораздо удобнее с использованием командлетов из одноименного модуля. Однако, если на каком-либо компьютере этот модуль не установлен и PowerShell Remoting нам в данный момент по каким-то причинам недоступен, мы можем использовать ADSI — Active Directory Service Interfaces. Когда мы обращаемся к Active Directory при помощи ADSI, например, так большинс
* Color-coded output depending upon the Value of the Datapoint; Above or below predefined thresholds
* Display custom information on X and Y-Axis labels
* A Graph in the console that is independent and fully customizable, not like Task Manager’s (no need to switch to Performance Tab) and,
* Could be easily used in any Powershell script to monitor performance on any defined parameter, which I see as the biggest benefit of the function.
Last Friday I had the pleasure to speak at BSides Amsterdam, a security centered conference that hosted its first iteration in Amsterdam. I could not pass up on the opportunity to attend this event. Here is an excerpt about the BSides concept from their site at bsidesams.nl: Security BSides is a community-driven framework for building events, […]
Invoke-DscResource is a cmdlet available in PowerShell version 5 and above. It allows you to run a Dsc resource method without having to generate a mof document or even write a configuration document. In this blog post you’ll learn how to use a ModuleSpecification to tell the cmdlet which version of a resource module to use. Why would you need to do that? By default, the cmdlet will use the latest version of the resource called which might not be what you want.
You’ve signed up for a Microsoft Azure account and you’ve installed the Azure Resource Manager PowerShell cmdlets on your computer. You login to Azure from PowerShell. You’ll normally see most people use Login-AzureRmAccount, but that command is an alias (Login isn’t an approved verb). Login to Azure and provide the account login information when prompted: Several of the cmdlets in the Azure Resource Manager PowerShell module require a location (a region) to be specified when creating things.
This is going to be the first in a series of posts related to working with module tools.
In my previous article, I talked about what tools module authors should leverage.
Now I want to walk through using these tools and demonstrate how they all come together.
To do this, we will be creating a new module called HideWindowsExplorerDrives.
The purpose of this module is to make hiding and showing explorer drives easier.
ServiceNow is a cloud computing company whose software is used for IT Service Management based on ITIL standards. They’ve got a bunch of different modules for managing problems and incidents, operations management, performance analytics, and more.Read More...
If you are creating PowerShell scripts, tools or modules today, you are most likely using Git. What? You’re not? Is it because you haven’t gotten around to installing it? I have some “quick and dirty” PowerShell hacks to help you out on Windows systems. Linux boys and girls already know what to do. Naturally you […]
In this article, we are going to introduce a new PowerShell module called PSProductivityTools.
Time management is something most people is having to face every day. At work, we try to be as productive as possible. However, it may not be easy due to many distractions during a work day.
Many books are written on this topic, and several techniques exists for trying to put your available time into a system.
Not too long ago I posted a PowerShell function that could provide detail abut the PowerShell engine driving your current PowerShell session. I like having a function that writes an object to the pipeline, can take parameters and offer help documentation. But there’s an alternative approach you could also take. Most of the information is […]
I came across some fun stuff on the internet, so I wrapped it inside a Powershell Function for this blog post. The idea is to get weather report in Powershell console using this cURL implementation converted into Powershell function below Just pass a name of the City as a parameter to the Function to get… Read More Get-Weather report using Powershell
If you follow me on Twitter, then I’m sure you’re aware that I’ve been using nothing but VS Code (Visual Studio Code) as a replacement for the PowerShell ISE (Integrated Scripting Environment) for the past couple of weeks and while I had tried it in the past, I didn’t previously think it was ready for prime time. That’s now changed with all of the updates and work that has gone into it.
Introduction: A couple of URL shortening services like Google and TinyURL are available over the Internet, and I’m a big fan as Short or Tiny URLs as they are very useful to share contents on social media (Eg. Twitter with 140 Char limit), especially for bloggers, but they can be used for malicious purposes by… Read More Expand Short URL using Powershell
Pester is a PowerShell behavior-driven development (BDD) style testing framework. But, really all you need to know about it before getting started, is that it’s a testing framework and it can be used to automate the testing of your PowerShell code. You might think to yourself well what’s the point of that? I already wrote my PowerShell function, all I need to do now is run it and see if it does what I want.