My PowerShell Scripts - Systems Administration #powershell #script #sysadmin
Summary
TLDRIn this informative video, the speaker discusses the utility of a custom PowerShell module they've created for work. They've consolidated multiple scripts into one, which can be used by changing the file extension from .PS1 to .PSM1. The module contains individual functions that can be imported into a PowerShell profile for easy access. The speaker highlights several functions, including a ping utility, a function to retrieve the currently logged-in user on a remote computer, a function to check system uptime, and a tool to examine installed drivers and their installation dates. They mention that these scripts will be shared on their website, PCXCOM, and encourage feedback for improvement.
Takeaways
- 📚 The speaker has combined multiple useful scripts into a single module for convenience at work.
- 🔄 To use the module, one must change the file extension from .PS1 to .PSM1.
- 📝 The module contains individual functions that can be imported into the shell for frequent use.
- 💡 One function mentioned is a quick ping script, which can be invoked by typing 'P' followed by a domain name.
- 🖥️ The 'Get-LoggedIn' function is highlighted as the speaker's most frequently used script, which retrieves the currently logged-in user on a local or remote computer.
- 👥 The 'Get-LoggedIn' function can handle multiple computer names at once, separated by commas.
- ⏱️ The 'Get-UpTime' function is used to check how long a computer has been running, which is helpful for verifying system restarts.
- 🛠️ Another script provided by a system admin helps to check installed drivers and their installation dates for specific hardware.
- 🔍 The hardware script can be filtered to show only drivers related to a certain name, such as 'Intel'.
- 🔗 The speaker plans to make these scripts available on a website, with a link expected to be provided in the video description.
- 🗣️ The speaker invites feedback and suggestions for improving the module or adding new tips and scripts.
Q & A
What did the speaker do with the scripts they use at work?
-The speaker combined several useful scripts into one script, saved it as a module, and changed the file extension from .PS1 to .PSM1.
How does one use the module created by the speaker in their PowerShell environment?
-To use the module, one needs to import it in their PowerShell profile script.
What is the purpose of the 'P' function mentioned in the script?
-The 'P' function is a quick ping script that the speaker occasionally uses, although they find typing 'ping' directly quicker due to familiarity.
How can the 'Get-LoggedIn' function help in a work environment with many computers?
-The 'Get-LoggedIn' function retrieves the user currently logged into a specified computer, which is useful for quickly identifying who is logged into a computer, especially in an environment with thousands of computers.
What does the 'Get-UpTime' function do and why is it useful?
-The 'Get-UpTime' function shows how long a computer has been up and running, which is helpful for verifying system restarts and uptime.
How can the 'Get-Hardware' function assist in managing drivers on multiple computers?
-The 'Get-Hardware' function allows users to check what drivers are installed on a computer and when they were installed, aiding in driver management and troubleshooting.
What is the benefit of having individual functions within a module?
-Having individual functions within a module allows for modularity and reusability, making it easier to manage and maintain the code, as well as to use specific functions as needed.
How can the speaker's scripts be accessed by those interested?
-The scripts will be made available on the speaker's website, PCXCOM, with a link provided in the video description on the YouTube page.
What does the speaker suggest if someone has tips or suggestions for improving the scripts?
-The speaker encourages viewers to share their tips or suggestions for improving the scripts or adding features to the module.
What is the significance of changing the file extension from .PS1 to .PSM1 in PowerShell?
-Changing the file extension from .PS1 to .PSM1 signifies that the script is being used as a module in PowerShell, allowing for easier import and use of the script's functions.
How does the speaker organize their frequently used functions?
-The speaker organizes their frequently used functions in a storage area or script, making them available within the shell every time it launches.
Outlines
🛠️ PowerShell Script Module for IT Efficiency
The speaker discusses creating a PowerShell script module that consolidates multiple scripts into one for increased efficiency at work. The module is saved with a .psm1 extension and includes individual functions. The speaker mentions that a simple 'ping' script is included, which they don't use often but find neat. The 'get-loggedIn' function is highlighted as the most frequently used, allowing the user to quickly determine who is logged into a local or remote computer. The 'get-upTime' function is also mentioned, which provides information on how long a computer has been running. Lastly, a function provided by a system admin is described, which helps to check installed drivers and their installation dates for specific hardware. The speaker intends to make these scripts available on a website for others to use and encourages feedback for improvement.
Mindmap
Keywords
💡Scripts
💡Module
💡File Extension
💡Import
💡Functions
💡Ping Script
💡Get-LoggedIn
💡Get-UpTime
💡Hardware Version
💡PCXCOM
Highlights
The speaker consolidated multiple useful work scripts into one module.
To use the module, change the file extension from .PS1 to .PSM1.
Import the module in the PowerShell profile to have it available at every shell launch.
The module consists of individual functions stored in a 'storage area'.
A quick ping script is included, which can be invoked by typing 'P'.
The ping script returns 'true' if the host is reachable, otherwise 'false'.
A function named 'get-loggedIn' retrieves the user currently logged into a remote computer.
Tab completion is supported for ease of use within the 'get-loggedIn' function.
The function can handle multiple computer names for checking logged-in users.
A 'get-upTime' function is used to check how long a computer has been running.
The 'get-upTime' function provides information in days, hours, and minutes.
A script to check installed drivers and their installation dates is included.
The hardware information script can filter results by name, such as 'Intel'.
The speaker plans to make these scripts available on the PCXCOM website.
A link to the scripts will be provided in the video description on the YouTube page.
The speaker invites feedback and suggestions to improve the module and scripts.
Transcripts
there's a few scripts that I use at work
that come in very handy and what I did
is I actually bumped them into one
script and saved it as a module and the
only thing you have to do is change the
file extension from PS 1 to PS m 1 to
make it a module and then what I do is
in my pull file I just import this
module and so let's go ahead and take a
look at what's in this module now you'll
notice they're individual functions and
that's all you got to do is create
individual functions and this is kind of
just like my storage script or storage
area where I store all these functions
that I I use frequently and that I want
to have available within the shell every
time it launches the first one now this
one I'll be honest with you I don't use
it much but I did I saw it on I don't
remember whose blog it was but maybe was
Don Jones or something but I thought it
was pretty neat and I do find myself
using it every once in a while and all
it is is a quick little ping script now
to me it's kind of quicker just to type
ping because I'm so used to it but you
know it's kind of neat to to see it and
but you know what I don't think I have
this function and I just named it the
letter P I don't think I have this I
don't have I don't think I've imported
this module yet so let's test it if I
just do P and then google.com well it
does work so I do have it imported so
disregard so it's just basically saying
true it's paintable now if we try to
paint something else it's false so
that's all that one does now the next
one here this one I use all the time at
work this is probably my number one
script that I use or a function that I
use I just called it get logged in and
all it does basically is gets or
retrieves the user that's currently
logged into the remote computer now I
don't have a remote computer here to
test with but I can just do it on this
local machine so if we do get - logged
in and tab completion works and I'm just
gonna put in localhost here's where you
would just normally put in the remote
computer name hit enter and it says
the computer name and who's logged into
it now for instance we want to do
multiple computers at once all you gotta
do is put a comma
I'll just put one and it'll just go down
the list I find this very useful
especially at work where we have
thousands of computers and different
users and I just need to see who's
logged into a computer really quick so
the next one is getup time now I do use
this one quite frequently too you know I
have some users ask him have you have
you restarted computer and they'll say
yeah and then I'll double check it real
quick and they turns out they haven't
this one just goes and lets you know how
long the computer's been up so it's
clear this if we do get - uptime and
then you can put in your computer name
for instance here we'll just do
localhost tells you how many days the
computer name eight seconds the minutes
and hours that one comes in pretty handy
- and this last one it's provided via
one of the system admins at work I'm not
sure if he wrote it or or I got it
somewhere or whatnot but this one comes
in handy if you want to check like what
drivers are installed and maybe when the
drivers were installed for a particular
piece of hardware now if you just run it
by itself without a parameter so let's
just do get hardware version it's built
nope we need a computer name on this one
so we're just gonna do localhost
so that's gonna go through grab all the
information about all the hardware and
you know that's a lot of reading and all
this stuff but let's just break it down
to let's say we just want stuff that's
related to the name or that contains the
name Intel for like the NIC card or
something or the CPU so here you can see
we got a gigabit network card the driver
date was 229 2012 and the driver version
so this comes in handy if you're trying
to figure out what computers have what
versions of what driver and when they
were installed and all that stuff so
this one this one comes in pretty pretty
handy now all these scripts are going to
be available I'm gonna make them
available on the site so check out PC
XCOM and there should be a link in the
description under this video on the
YouTube page so alright guys hopefully
you found this helpful and if you have
any
tips for you know what you would like to
see in this kind of a module or tips to
make these scripts better please don't
hesitate to let us know
Voir Plus de Vidéos Connexes
Pi-Hosted : Installing JDownloader and File Browser On The Pi Docker Server Part 4
Parent Functions
ES6 #1: Spread & Rest Operator in ES6 in JavaScript in Hindi | Technical Suneja
pro hacker teaches you how to bypass this!
Percentiles, Quantiles and Quartiles in Statistics | Statistics Tutorial | MarinStatsLectures
Learn Functions – Understand In 7 Minutes
5.0 / 5 (0 votes)