Empty the Recycle Bin with PowerShell and the Task Scheduler
SID-500.COM
by Patrick Gruenauer
1w ago
In this post I will show you how to empty the recycle bin automatically. For this I will use PowerShell and Scheduled PowerShell Jobs. So I will show two ways how to do this (second one is recommended). Option 1: Task Scheduler The Task Scheduler is a feature in Microsoft Windows. We create a file and this file, which contains Clear-RecycleBin, is executed according to our schedule. Here is the code. Information must be entered in line 3 to 5. ### This script creates a Scheduled Task to clear the recycle bin every x hours $hours = '12' $jobname = 'ClearRecycleBin' $user = 'azuread\patrickgr ..read more
Visit website
How to create a PowerShell Module with multiple Functions
SID-500.COM
by Patrick Gruenauer
3w ago
In this blog post, I will show you how to create a module with multiple functions using an example. You will see that this is not rocket science. Let’s jump in. In order to use multiple functions in a module, we have to declare them as functions to export. This also means we need a module manifest file with that statements in it. Objective The goal of this tutorial is to provide two functions in a module named Patrick. The two functions are called Get-SmallFiles and Get-BigFiles. Creating a Module Folder “Patrick” First of all, we need to create a module folder. We can choose between three fol ..read more
Visit website
Create multiple DNS A Records with PowerShell
SID-500.COM
by Patrick Gruenauer
1M ago
Imagine you have to create hundreds or thousands of DNS records. Do you want to do that one by one? Surely not. I will show you an example how to create Beamer01 – Beamer100 and assign an IP address at the same time. Let’s jump in. The Objective Let’s say we want to create A Records Beamer01 – Beamer100 with the IP-Addresses 192.168.1.1 – 192.168.1.99. The Code Here is the example code you can build on. The script creates Beamer01 – Beamer99 with the corresponding IP addresses. $ip = 1..99 foreach ($i in $ip) { If ($i -lt 10) { Add-DnsServerResourceRecord ` -ZoneName 'test.local' ` -Name ..read more
Visit website
PowerShell: Creating functions that accept Pipeline Input
SID-500.COM
by Patrick Gruenauer
2M ago
So you have already created a function and now you want to enable pipeline functionality? Yes? Then read on. In this blog post I will show you an example on how to build functions that accept pipeline input. Let’s dive in. Goal Everything we want to achieve can be seen in this screenshot. Our Function Test-PipelineInput accepts objects that passes the PowerShell pipeline. This feature is called PipelinInput. Creating an Advanced Function that accepts Pipeline Input Here is an example on how to achieve this. function Test-PipelineInput { param ( [Parameter(ValueFromPipeline=$true ..read more
Visit website
5 Ways to install PowerShell 7 on Windows
SID-500.COM
by Patrick Gruenauer
3M ago
PowerShell 7 is the successor to PowerShell 5.1. It’s fast, reliable and it is cross-platform. Without a doubt, PowerShell 7 is the future. You can install PowerShell 7 on Windows, Linux and MacOs. In this blog post I show you 5 ways to install PowerShell 7 on windows computers. 1. GitHub GitHub is a developer platform. Just search for PowerShell and you will get the download link. 2. Microsoft Docs | Microsoft Learn Second option is via Microsoft Docs. 3. winget on Windows 11 Probably the most attractive and coolest option is to do without a web browser. Just use winget on Windows 11. winge ..read more
Visit website
PowerShell 7: Enable SSH Remoting
SID-500.COM
by Patrick Gruenauer
3M ago
With Powershell 7, we can enable and use SSH Remoting. Unlike WinRM, SSH is more popular because it is a more familiar technology and is also available on other platforms. In this post I will show you how to easily enable SSH on PowerShell 7 with a few lines of code. Install OpenSSH Client and Server We now install SSH over the Internet. So you should make sure that your computer has access to the Internet. Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0 Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 Configuring the SSH Service Next, we need to configure the SSH ..read more
Visit website
Neuer Udemy Kurs: PowerShell 7 für Einsteiger und Profis
SID-500.COM
by Patrick Gruenauer
3M ago
Liebe FollowerInnen! Ein neuer 15-stündiger Kurs ist online: PowerShell 7 : Master Class für Einsteiger und Profis Wenn Sie sich für PowerShell interessieren, dann können Sie einen Blick in die Vorschauvideos werfen. Vielleicht ist dieser Kurs interessant für Sie. Wenn ja, dann können Sie folgenden Gutschein Link verwenden um diesen Kurs für EUR 9,99,– (gültig bis 29.10.2022) zu erwerben. Gutscheincode: F3EE2B8A1D0D7008D86A ODER Link: https://www.udemy.com/course/powershell-7-master-class-fur-einsteiger-und-profis/?couponCode=F3EE2B8A1D0D7008D86A Liebe Grüße P. Gruenauer ..read more
Visit website
PowerShell QR Code Generator for WIFI Networks
SID-500.COM
by Patrick Gruenauer
4M ago
If you use QR codes instead of passwords, you increase the user experience. Did you know that you can create such a QR code with PowerShell without any 3rd party tools? No? Then go ahead. Installing QRCodeGenarator Module First we need to install a module. Make sure that your computer has a connection to the internet. Open PowerShell and install the module. Install-Module -Name QRCodeGenerator -RequiredVersion 2.4.1 Next, hit the keys to retrieve all commands of this powerful module. Get-Command -Module QRCodeGenerator To create a QR code for WIFI we need the New-QRCodeWifiAccess cmdle ..read more
Visit website
List all logged on Users with quser.exe and PowerShell
SID-500.COM
by Patrick Gruenauer
4M ago
In this short article I will show how to list all logged on local users with the quser.exe tool. Quser displays information about logged on users on the local computer and on a Remote Desktop Session Host server. PowerShell Code Enter the code below to determine all logged on users. Multiple users, if any, will be separated by comma. $users = quser.exe | Select-Object -Skip 1 $unames = @() foreach ($u in $users) { $uname = ($u.trim() -replace '\s+',' ' -replace '>','' -split '\s')[0] $unames += New-Object psobject -Property ([ordered]@{ 'Logged in Users' = [str ..read more
Visit website
Monitor Network Connectivity with PowerShell 7 (Successful Pings)
SID-500.COM
by Patrick Gruenauer
5M ago
Recently, I have created a script that returns a beep sound when the connection is re-established. I would like to share this script here on my website. Assume your network connectivity is broken. You wait until the connection is restored. In addition, you want to hear a sound when the connection is re-established. For this task, just use my script. Note that the ping is performed 10000 times. This is realized by $_ and 1…10000. This script was tested in PowerShell 7. 1..10000 | ForEach-Object { If ((Test-Connection -ComputerName 8.8.8.8 -Count $_).Status.Value__ -eq '0') { [System.Conso ..read more
Visit website

Follow SID-500.COM on Feedspot

Continue with Google
OR