Posts

Showing posts with the label POWERSHELL

How to get llama 2 up and running , in a VM, with no GPU, and limited memory on Ubuntu

Image
OK I decided to write this up after unsuccessfully being able to find all the required info I needed in one place. In this setup we will be using Ubuntu Server 22.04.2 LTS as the OS. I have this running on a home lab ESXi server 8, on a HP Compaq Pro 6300 SFF CPU = Intel Core i7-3770 Installed Memory 16 GB I have some 10K SAS drives installed for the VM's If you have not already, navigate to  Get Ubuntu Server | Download | Ubuntu and download the 22.04.2 LTS ISO Next Lets create our VM that we are going to run this in. *Note Im using ESXi however you can probably do this in Workstation, Fusion, VirtualBox etc The main things to note on the VM creation. Set Ubuntu 64 bit as the guest OS Set your CPU relevant to the physicals CPU, I will be starting with 4 VCPU Set your Memory to as much as you can tolerate, I will be using 12 Disk Space - we are creating a 100G swap file, and the rest of the file can take up some room , so more is better if you can afford it Dont forget to add the U

Configure windows (and MAC) to point to a specific DNS server for Specific domain

 I have probably searched off an on for this solution for about 10 years at this point, and always found some other way to work around the issue. Well today I was searching for some other DNS settings and found this: https://docs.microsoft.com/en-us/powershell/module/dnsclient/add-dnsclientnrptrule?view=windowsserver2022-ps And it actually works! So here is my example: Add-DnsClientNrptRule -Namespace ".universe.lab" -NameServers "10.10.1.1" Ran this as an admin I want any thing going to 'universe.lab' (dont forget to pre-pend the "." ) to go to 10.10.1.1 And then you can check what you have configured PS C:\WINDOWS\system32> get-DnsClientNrptRule Name                             : {2942DF55-16A3-4EED-B71B-7274B18F4FED} Version                          : 2 Namespace                        : {.universe.lab} IPsecCARestriction               : DirectAccessDnsServers           : DirectAccessEnabled              : False DirectAccessProxyType         

Sleep Progress Bar for Powershell \ Power-CLI scripts function

Image
I used this to update my lab power shell scripts so that during the sleep cycle , I have some indication of where we are at. You can read about these scrpits here https://jeramythompson.blogspot.com/2021/08/powercli-script-creating-instant-clone.html https://jeramythompson.blogspot.com/2021/08/vmware-vsphere-vcenter-and-esxi-home.html The End result will look like this This is achivied by creating a simple function at the top of the script and calling it later: ----------Here is the Function ------------------- function Get-SleepTimer{ param ( [int]$Time ) $Lenght = $Time / 100 For ($Time; $Time -gt 0; $Time--) { $min = [int](([string]($Time/60)).split('.')[0]) $text = " " + $min + " minutes " + ($Time % 60) + " seconds left" Write-Progress -Activity "Watiting for..." -Status $Text -PercentComplete ($Time / $Lenght) Start-Sleep 1 } } -----------------End Function--------- And we can simply call this function and pass the number of s

VMware vSphere vCenter and ESXi Home Lab shutdown script with PowerCLI

Some times you need to shut down your lab in as efficient way as possible. I do this quite often as I don't like leaving my home lab running during various events (thunderstorms, weekends , vacation etc). And I really dont like having to click , wait, click, wait, click.... wait some more to get every thing down. So I wrote this script to power down my lab, Ill walk you through what it does and the completed version will be at the end of this post. (I'm also including a start-up script I use as well) First we need to import our power CLI modules and tell the script to ignore any self-signed or Invalid certificates ( If you want more info on setting up powerCli see the beginning of this post for more info) ------------------------------------------------------------------- Import-Module VMware.PowerCLI Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false ------------------------------------------------------------------- Now we need to setup our credential

Extract remote DNS to local hosts file

So with the whole work from home process, my company recently made changes to its VPN policy to block local DNS queries. This has completely screwed up my work flow for testing. So with a bit of google-ing  and duct taping some code I have come up with a simple powerslell script to extract the DNS zone from my lab to my local host file. Enjoy! #VARIABLES $scriptpath = $MyInvocation.MyCommand.Path $dir = Split-Path $scriptpath $CSV = "$dir\DNS_A_records.csv" #parameters $DNSServer = "dc1.home.lab" $Zone1 = "home.lab" #$Zone2 = "me.myzone.local" #SCRIPT MAIN clear $DNS_Zones = @() $DNS_Zones += $Zone1 #$DNS_Zones += $Zone2 $hosts = @() $DNS_Zones | % {     $zone = $_     Write-Host "Getting DNS A records from $zone"       $DNS_A_records = @(Get-WmiObject -Class MicrosoftDNS_AType -NameSpace Root\MicrosoftDNS -ComputerName $DNSServer -Impersonation 3 -Credential HOME\administrator  -Filter "ContainerName = `'$zone`'")    

UAGCommander

Image
UAG Commander Introducing a new way to manage the deployments of your VMware UAG's With UAG Commander, you can consistently deploy UAG's with the already existing powershell script. No more guessing on the correct syntax, order / location of the correct settings, or remembering what settings you used previously. UAG commander currently has the following features: Gui for Automatic creation of properly formatted INI files Automatic backup of INI files before deployment (up to five backups are auto rotated) Deployment through existing powershell scripts Importation of existing INI files Auto enumeration of datastores, networks, and hosts Check the download page for the latest version and updates Requirements VMware OVF tool vSphere 6.5 (the application calls 6.5's rest api to get the correct values) UAG powershell scripts from VMware .Net 4.6 or later installation is straightforward run the installer (if you do not have OVFTool already installed a w

VMware View Security Server Dynamic IP update script.

To go along with my previous post http://jeramythompson.blogspot.com/2015/09/vmware-horizon-access-point-dynamic-ip.html Im adding a new script for dynamically updating a security server. Simply replace the cn=SEC with the name of your security run the scrip on a schedule on your connection server as some one who has access to the ADAM database. Enjoy: https://drive.google.com/open?id=0Bwf718kXFFS8WVVvR1NBS1EtaVU

Historical Home Directory Usage

One of the issues we have to monitoring disk usage on our home directories. I needed a way to monitor who was using the most space, and to find out quickly who had used the most space most recently. So to start out i have created a simple powershell script to get the entire home directory size, and put that information into a SQL database. First i get a listing of all folders in the folder containing the home directories then for each Folder, i get the total size, and send that info to SQL Tables are setup [Name],[MB_Used],[Date]  , the date field is auto popluated dir D:\homeDirs | ForEach-Object { $colItems = (Get-ChildItem Z:\HOME\$_ -recurse | Measure-Object -property length -sum) $DasName = $_ $DasSize = "{0:N2}" -f ($colItems.sum / 1MB) $SQLServer = "SQLSERVER" $SQLDBName = "DATABASE" $SqlQuery = "insert into dbo.TABLENAME ([Name],[MB_Used]) Values ('$DasName','$DasSize')" $SqlConnection = New-Object System.

Powershell - Get folder size

So i ran into a situation where i needed to get the size of a set of folders, allot of folders. I created this powershell script to do a couple of things 1. point to the root of where the folders reside 2. list all the folders in that directory 3. recursivly go through each folder and sub-folders to and get the total sum of the size of folders 4. out-put the size and name of folder both on screen and to a text file. Enjoy! $rootPath = "C:\Folders\" $colItems1 = Get-ChildItem $rootPath foreach ($i in $colItems1) { $colItems = (Get-ChildItem -recurse "$rootPath\$i" | Measure-Object -property length -sum) "{0:N2}" -f ($colItems.sum / 1MB) + " MB,$i" "{0:N2}" -f ($colItems.sum / 1MB) + " MB,$i" >>C:\result.txt }

Historical Disk usage with Powershell and SQL

Checking hard drive space gets old, and if you want historical data it was a manual processes, so i created this script i run once a day to update a SQL database, and connect to it from excel to give me a historical data usage on our shared drives. Enjoy.

Enumerating Groups of users and properties with Powershell ADSI

So the other day it was brought up to give a user access to see what users are in a specific set of groups in a specific OU. I did not want to install the admin tools just so they could use the ActiveDirectory modules, so i had to write this script using only ADSI. using ADSI only requires the end user to have read access to the objects. Here ya go have fun. # Group enumerator script by Jeramy Thompson # Downloaded from http://jeramythompson.blogspot.com/ # Change $ouPath to the path of groups you want to enumerate # To popluate different user properties # change $userCN.mail to $userCN.(property) for example # if you wanted the samaccount name change it to # $userCN.sAMAccountName # # # $ouPath = "OU=OUNAME,DC=netbiosdomain,DC=domain,DC=com" [void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") [void][System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") $Form1 = New-Object System.Windows.F