Posts

Showing posts from 2025

Create multiple Azure files shares using Powershell

If you have to create multiple shares for an Azure files instance as part of a migration or new deployment it can be very time consuming. With this script you put the name of the shares in a txt file called "shares.txt" and it will loop through and create them all and assign them to the hot tier. <# .SYNOPSIS Created by James Lambert www.roonics.com .DESCRIPTION This script creates shares from a txt file in Azure and set's their access tier .EXAMPLE .OUTPUTS .NOTES #> # CONFIG START $file = Get-Content -Path "shares.txt" $accessTier = "Hot" $tenant = "<tenant id>" $subscription = "<subscription id>" $resourceGroupName = "<resource group>" $storageAccountName = "<storage account name>" # CONFIG END # CONNECT TO AZURE Connect-AzAccount -Tenant $tenant -SubscriptionId $subscription # GET STORAGE KEY $storageKey = (Get-AzStorageAccountKey ` -ResourceGroupName $resour...

Apply tags to azure resource groups from csv file

This script is used to apply tags as per a csv file. Tags will be applied in uppercase. If a resource group is present in the csv but not in Azure it will be skipped. A log file will be generated in the log folder. A backup of the resource groups previous tags and values will be created in the backup folder. CSV should be formatted as the Example file and saved as tags.csv in c:\temp\tags unless you specify differently under the config section An example csv file can be downloaded here <# .SYNOPSIS Created by James Lambert www.roonics.com .DESCRIPTION This script is used to apply tags as per a csv file. Tags will be applied in uppercase. If a resource group is present in the csv but not in Azure it will be skipped. A log file will be generated in the log folder. A backup of the resource groups previous tags and values will be created in the backup folder. .EXAMPLE CSV should be formatted as below or see the example file and saved as tags.csv in c:\temp\tags unless you specify d...

List object contributors in all Azure subscriptions with Powershell

Image
The below script will loop through all Azure subscriptions excluding Visual Studio subscriptions, it will then look at every object and list/export everyone who has a role that has the word "Contributor" in it. Example below: <### .Synopsis Created by James Lambert www.roonics.com .DESCRIPTION This script will connect to Azure and cycle through all subscriptions listing all the objects and who has a role which has "Contributor" in the name .EXAMPLE Run the script and sign in to Azure .OUTPUTS A file csv file will be created for each subscription named "contribuators_subscription.csv" in c:\temp A total number of contributors will be added to the bottom of the csv .NOTES Keep in mind this will only be able to look at subscriptions you have permissions to. This will also skip the Visual studio subscription using a if the name like 'visual' statement ###> ### Config and clear screen cls $Path = "C:\Temp\" $f...

List printers and IP addresses on a windows server using Powershell

Image
  <### .SYNOPSIS Created by James Lambert www.roonics.com .DESCRIPTION Collect port names and host addresses into hash table .EXAMPLE .OUTPUTS .NOTES ###> $hostAddresses = @{} Get-WmiObject Win32_TCPIPPrinterPort | ForEach-Object { $hostAddresses.Add($_.Name, $_.HostAddress) } Get-WmiObject Win32_Printer | ForEach-Object { New-Object PSObject -Property @{ "Name" = $_.Name "DriverName" = $_.DriverName "Status" = $_.Status "HostAddress" = $hostAddresses[$_.PortName] } }

Stop and disable a Windows service using powershell

Populate "computers.txt" with all the server names you wish this to run on then adjust the script to fit the service you require. <### .SYNOPSIS Created by James Lambert www.roonics.com .DESCRIPTION Stop and disable a Windows service using powershell Populate "computers.txt" with all the server names you wish this to run on then adjust the script to fit the service you require. .EXAMPLE .OUTPUTS .NOTES ###> $SrvNames = Get-Content -Path 'C:\data\scripts\computers.txt' foreach ($Server in $SrvNames) { Get-Service -Name "Rubrik Backup Service" -ComputerName $Server | Stop-Service -PassThru | Set-Service -StartupType disabled }

Split file every xxx lines with Powershell

Image
I recently ran in to an issue whilst using CommVault to restore some archive files from it's HSM. You have to run the gxhsmutility to scan the files to check if any stub files remain, if there is it outputs what is called a map file, you then run the restore again pointing to said map file. The problem with this was that if the map file was over 100,000 lines the recovery would just crash, so I wrote this to split the map file out in to multiple map files I could then use to recover the data. <### .SYNOPSIS Created by James Lambert www.roonics.com .DESCRIPTION This script will get a list of all files in the "Files_to_split folder" then loop through each file and split every XXX numbers of lines (set in the config) .EXAMPLE .OUTPUTS .NOTES ###> ### Config $FilesToSplitDir = "Files_to_split\" $SplitFilesDir = "Split_files\" $SplitFileLines = 100000 $padding = " " cls ### Check if source folder is present if (!(Test-Path ...

Add random number prefix to filename with Powershell

This allows you to add a randomly generated number to the prefix of a bunch of files. In the below example we are adding a random prefix to every *.jpg file. <# .SYNOPSIS Created by James Lambert www.roonics.com .DESCRIPTION This allows you to add a randomly generated number to the prefix of a bunch of files. In the below example we are adding a random prefix to every *.jpg file. .EXAMPLE .OUTPUTS .NOTES #> $files = Get-ChildItem "C:\temp\files" -Filter *.jpg foreach ($file in $files) { $prefix = Get-Random $newFileName = "${prefix}_${file}" Rename-Item $file $newFileName }

Ping Monitor Batch File With Colour Changes

Image
A script to continuously monitor an IP address and give clear indications when up or down with timestamp, handy for trouble shooting a network/server issues. Copy and paste in Notepad and save as a batch file: @echo off SET OUT=0F color %OUT% mode 44,20 echo mode 44,20 echo off & cls Title = Ping monitor set /p IP=Enter your IP Address : :top set mytime=%time:~0,2%_%time:~3,2%_%time:~6,2% set mydate=%date% PING -n 1 %IP% | FIND "TTL=" >nul IF ERRORLEVEL 1 (SET OUT=4F & echo %mydate% : %time:~0,2%:%time:~3,2%:%time:~6,2%% : Down & Title Down %IP%) ELSE (SET OUT=2F & echo %mydate% : %time:~0,2%:%time:~3,2%:%time:~6,2%% : Up & Title Up %IP%) color %OUT% ping -n 2 -l 10 127.0.0.1 >nul GoTo top

ITIL V4 Foundations

Service management - is defined as a set of specialised organization capabilities for enabling value to customers in the form of services. Value - the perceived benefits, usefulness and importance of something. Customers - define requirements for services and take responsibility for outcomes. Users - use services. Sponsors - authorize the budget for service consumption. Supplier - external partner who provides services to the organization. Organization - a group of people that has its own function, responsibilities and authority to achieve specific objectives. A service is a means of enabling Value co-creation by facilitating desired outcomes for customers without the customer having to manage specific costs and risks. Product - a configuration of resources, created by the organization that will be potentially valuable to customers. Service offering - a specific mix of services and products to a specific customer: goods - ownership is transferred to customer Access to resources - Owner...

AZ-104 - Microsoft Azure Administrator

  Manage Azure identities and governance RBAC Roles Contributor Full access to manage Azure resources Cannot assign roles in Azure RBAC Owner Full access to manage Azure resources Can assign roles to other users in Azure RBAC Reader Can view resources but cannot make changes User Access Administrator Can manage user access to Azure resources There is a limit of 2000 custom roles per tenant devtest labs user role only lets you connect, start, restart and shutdown virtual machines in azure devtest labs. You can assign custom roles to users, groups, and service principals at management group, subscription, and resource group scopes. Custom roles can be shared between subscriptions that trust the same Microsoft Entra tenant. There is a limit of 5,000 custom roles per tenant. (For Microsoft Azure operated by 21Vianet, the limit is 2,000 custom roles.) Custom roles can be created using the Azure portal, Azure PowerShell, Azure CLI, or the REST API. Azure Policy Used to ensure Azure resou...