Search This Blog

Thursday, April 18, 2024

Powershell - Create New Rocky OS Workstation VM

 Cent OS is dead. moving on to Rocky OS.

The initial work was in my blog post Powershell - Create New CentOS Workstation VM

I put the pile of code: https://github.com/LesleyPhillips/New-RockyLinux-20240307.ps1


This time around I'm working on Windows 11 Pro Hyper-V Manager


Here you can see me working on Postgres DB...



Wednesday, November 29, 2023

Powerball Statistics

 I had just finished learning R but was annoyed by it. So, in  learning to do Python, and running into so many Python Matplotlab examples, I decided to do it like that. I put the code blob here in github:https://github.com/LesleyPhillips/Powerball.py/blob/main/Powerball-20231004.py

Some takeaways... apparently there are functions for standard deviations and averaging. : )

Here are the results...




This code... 
  • Gets it numbers from 'https://data.ny.gov/api/views/d6yy-54nr/rows.xml?accessType=DOWNLOAD' 
  • It then loops through the XML data into white balls and red balls.
  • Plots the white ball data
  • Plots the red ball data.

You're done!   : )



Friday, September 15, 2023

How to Compile .vb Code

Ever needed to compile some .vb code? Here's how I did it today.



Given a text file called Helloworld.vb with the following content...

Imports System
Module HelloWorld
    Sub Main(args As String())
        Console.WriteLine("Hello World!")
    End Sub
End Module

You can create this file on any path you see fit with any editor Notepad, Notepad++, Atom, VSCode, pick one.  : ) 

For this example I'm using Visual Studio 2022, which look like this...

Visual Studio defaults to creating content in your %userprofile%\source\repos dir. On creating the VB Console project HelloWorld, it saved the source as %userprofile%\source\repos\HelloWorld\HelloWorld\HelloWorld.vb. 

Make sure the latest vbc.exe is on the path.
On My Windows 11 PC it existed in...
C:\Windows\Microsoft.NET\Framework64\v4.0.30319.

With Visual Studio Community Edition 2022, I found it located in C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Roslyn.

Make sure to search and use the on you want to work with.


Start cmd

Issue commands to go to the directory with your source .vb file

>c:
>cd %userprofile%\source\repos\HelloWorld\HelloWorld
>dir

You directory may look like the following...
Visual Studio will also create other legacy elements for managing the code within its environment. For our purposes they are not needed and can be ignored.

Issue the follow commands

>vbc HelloWorld.vb

** Vbc (the older .Net version) will tell you that there is a better method to use called Roslyn which comes automatically with Visual Studio.   

 

If you are using the Roslyn vbc it will look like this...



 
 

>dir

There's our .exe file!   :)

Run HelloWorld

From the cmd prompt issue the command "helloworld"


It works!   : )

You now have a .exe you can use anywhere.
 





Friday, February 25, 2022

Sharepoint Redirect to Notes:// - Part II

 Back in Thursday, November 19, 2015, I showed a bit if html that can be used as a redirector for custom URL handlers. Since then Microsoft has hardened their products a bit and an extra step is needed.

Create the content as shown in Sharepoint Redirect to Notes://.

Save the file, with the content shown in the post, with the extension as .http

Test it by double click the file. IT should open a browser tab and automatically launch the application as expected.

Copy the .http file, then change the extension to .aspx.

You typically cannot test this until it's used from a Sharepoint site.

Save the file on your Sharepoint site.

Test this by clicking on the file you just saved, it should behave as the redirector and open your application.

Get the URL to the .aspx file.

Test this by trying the URL in the address bar of a new browser tab or window, it should behave as the redirector and open your application.

On the Sharepoint page, modify the link to use the working URL acquired in the last step.

Test this by lots of happy clicks!    : )




You're done! 



Saturday, January 15, 2022

MyCompany Certificate Organization

I use a fictitious company called MyCompany for use in some of the things I describe in my writing..

I had done this write up a long time ago and it's influence can be seen in many of my post. I had done this to describe the naming of elements in a Domino DB environment, but many of these ideas are transferable to other directory structures. I'm putting this here so that others can see it as a template for themselves and maybe build on it.

If you want to see where it's been used, search this blog on "MyCompany".


Naming Conventions

Site Names

As far as sites are concerned, admins and business leaders need to come to their own terms. Traditionally, we have stuck with three characters representing a local name, the business unit, and the larger geography they exist in. For example:

        BMO - Butler Manufacturing Ohio
        MRO – Marysville Research Ohio

 Servers Names

Roles

  • SuperHubs - manage the replication and mail transfer between regions.
  • Hubs - can replicate application and route mail.
  • Spokes - are typically more specialized and are broken down into Application, Mail, Dev, QA, and other..

 Naming

Regional admins work with sites admins to work out the names, but should be  named after their functions. The only part which there is a hard rule are for the first two parts of the name.

  • The first character describes the server as an H (hub) server or an S (spoke) server. Superhubs are designated by Z.
  • Next is the site name (like JMO, MMO, PMO).
  • Lastly, the site specific unique identifier.

 Here are a few examples:
        HRSM0001/SRV/NA/MyCompany    Hub for Rochester, MA
        SRSMM001/SRV/NA/MyCompany    Mail server for Rochester, MA
        SRSMA001/SRV/NA/MyCompany    Application server for Rochester, MA
        HAMA001/SRV/NA/MyCompany    Hub server for Aubrey, Arkansas
        STMTBS01/SRV/NA/MyCompany    BlackBerry server for Townsend, Tennessee
        HAMA003/SRV/AU/MyCompany    Hub server for Albany, Australia
        ZMMO003/SRV/NA/MyCompany    Superhub in Marysville, Ohio
        SMMOM023/SRV/NA/MyCompany    Mail server in Marysville, Ohio

 My Company in North America

         /MyCompany

A regional admin will be given the regional cert to manage the creation of sites, servers and people. Regional admins can give sites a cert to manage servers and people.

 This is how NA (North America) is set up...

         /NA/MyCompany

         People
                Sales
                        /RSM/NA/MyCompany (Rochester, MA)
                Manufacturing
                        /AMA/NA/MyCompany (Aubrey, Arkansas)
                        /TMT/NA/MyCompany (Townsend, Tennessee)
                        /BMO/NA/MyCompany (Butler, Ohio, USA)
                        /EMO/NA/MyCompany (Euclid, Ohio, USA)
                        /JMO/NA/MyCompany (Jamestown, Ohio, USA)
                        /MMO/NA/MyCompany (Marysville, Ohio, USA)
                        /PMO/NA/MyCompany (Paulding, Ohio, USA)
                        /YMO/NA/MyCompany (Youngstown, Ohio, USA)
                        /WMK/NA/MyCompany (Weskan, Kansas)
                        /UML/NA/MyCompany (Uncle Sam, Louisiana)
                R&D
                        /MRO/NA/MyCompany (Marysville, OH)
                Canada (Sales, Mfg.)
                        /CN/NA/MyCompany (York Point, Prince Edward Island)
                Mexico (Sales, Mfg.)
                        /MX/NA/MyCompany (Oaxaca, Oaxaca)
        Servers
                /SRV/NA/MyCompany

Other Certs

        AF (Africa)
                /KSS/AF/MyCompany (Koidu Town, Kono District, Sierra Leone)
        AN (Antartica)
                /HRS/AF/MyCompany (Husvik, South Georga Island)
        AS (Asia)
                /GMC/AF/MyCompany (Qingzhen, Guizhou, China)
                /HMC/AF/MyCompany (Dongfang, Hainan, China)
                /MMI/AF/MyCompany (Parbhani, Maharashtra, India)
        AU (Australia)
                /AMA/AF/MyCompany (Albany, Western Australia, Australia)
        EU (Europe)
                /BME/EU/MyCompany (Sutton , Central Bedfordshire, England)
        SA (South America)
                /AMA/EU/MyCompany (Albany, Western Australia, Australia)

Many of these sites also have Sales included on the same certs.
There are also research facilities in India (MRI) and in England (BRE).

 

You're done!






Monday, May 17, 2021

Powershell - Create New CentOS Workstation VM

 

I put this initial rundown together for further coding thingies, like state checking and condition handling. Simple enough, with room to grow.   : )

I did this using on Windows 10 pro, with Hyper-V, using Powershell 7 for a CentOS workstation.

The pile of code: https://github.com/LesleyPhillips/Build-CentOSWorkstation.ps1/blob/main/Build-CentOSWorkstation.ps1

Normally, I just throw up CentOS minimal builds. This time I thought I'd try something prettier.




Thursday, October 1, 2020

Windows 10 Firewall Ports

From time to time I have to open a port to do something and close it back up when I'm done. As I do this fairly often (but not often enough to memorize) I created this recipe. There is an example using Docker below.


ugh! an error! what to do?



Background Information...


How to do this by the Windows user Interface (UI)

https://www.google.com/search?q=windows+10+firewall+enable+localhost%3A80+traffic

How to do this with Powershell

https://www.google.com/search?q=powershell+TCP+Port+80+in+Windows+Firewall 

https://docs.microsoft.com/en-us/powershell/module/netsecurity/new-netfirewallrule?view=win10-ps

https://serverfault.com/questions/883266/powershell-how-open-a-windows-firewall-port


 

Powershell 


Open the port


New-NetFirewallRule -DisplayName "Allow inbound TCP port 81" -Direction inbound -LocalPort 81 -Protocol TCP -Action Allow
Name                  : {af16f2f3-3221-4191-8c5a-f44a5f60ca58}
DisplayName           : Allow inbound TCP port 81


Test (while something is listening on the port)


 Get-NetFirewallRule -Name '{af16f2f3-3221-4191-8c5a-f44a5f60ca58}'

    ** You can also see this in the Windows firewall inbound rules

$tcp = New-Object System.Net.Sockets.TcpClient
$tcp.Connect("localhost","81")
$tcp.Connected
True


Close the port back up


Remove-NetFirewallRule -Name '{af16f2f3-3221-4191-8c5a-f44a5f60ca58}'

** If you test again, you should get a failure (or, your listening port was not blocked already). And, the control panel, on refresh, will show the rule is missing.

You're done! 



Example


As a semi-practical example, Start a Docker container, test and clean up. For this to be a real example, you would have to imagine that port 81 was the blocked port. On port 80, I got stuff running there already. So, I did this on port 81.


Open the Port


New-NetFirewallRule -DisplayName "Allow inbound TCP port 81" -Direction inbound -LocalPort 81 -

Start the getting-started container


docker run -d -p 81:80 docker/getting-started
6d44c9240e688b69a212fe24e58d2302b658bfcbcee787030943b04f12cde38b

Test that the container is running and on the proper port.


docker ps
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                NAMES
6d44c9240e68        docker/getting-started   "/docker-entrypoint.…"   6 seconds ago       Up 4 seconds        0.0.0.0:81->80/tcp   goofy_elion

Test the port via Powershell


(New-Object System.Net.Sockets.TCPClient –Argument "localhost","81").Connected
True

Open page in local browser http://localhost:81

 

Hooray! It works!   : ) 


Clean up the container


docker stop 6d44c9240e68
6d44c9240e68

Remove the firewall rule by Powershell


Remove-NetFirewallRule -Name '{af16f2f3-3221-4191-8c5a-f44a5f60ca58}'



You're done again!