Powershelling properly
The best ways to be able to look at your scripts some weeks/months/years after writing it is to script properly.
Here below is the format at always use, I use it as a script template :
The best ways to be able to look at your scripts some weeks/months/years after writing it is to script properly.
Here below is the format at always use, I use it as a script template :
PSScriptAnalyzer is a static code checker for Windows PowerShell modules and scripts. PSScriptAnalyzer checks the quality of Windows PowerShell code by running a set of rules. The rules are based on PowerShell best practices identified by PowerShell Team and the community. It generates DiagnosticResults (errors and warnings) to inform users about potential code defects and suggests possible solutions for improvements.
I wish you a really Powershell New Year 2019 !!!
Sometimes you get a requirement to start a Powershell script from an elevated prompt. Here is a quick function to check that :
function Test-ElevatedPrompt { [Security.Principal.WindowsPrincipal] $Identity = [Security.Principal.WindowsIdentity]::GetCurrent() $Identity.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) }
This will return a simple boolean so you can use it this way :
Install-Module BurntToast
Monitoring servers is an important thing, almost uptime of all servers. You should have some dedicated tools such as Zabbix, Nagios, etc… BUT ! Here is a script to generate an HTML report of all your servers uptime.
Those servers are all registered into AD and the ‘get’ is based on the operating system detected by AD.
Sometimes, for several reasons, you’ll have to import calendar events into users mailbox in O365.
That could be done using different methods, directly using a service account (with a mailbox !), impersonated (as if the user created the event).
Here below is a quick example of a small script (powershell of course ! )
PowerShell Conference Europe is the largest PowerShell-themed conference in Europe, and is held in Hanover, Germany each year. We attract speakers and attendees from all over the world, with such topics as security, DevOps, databases, core language features, optimization, DSC, best practices and much more.
Hey there !
A little tip I’ve just found, really usefull.
If you need to open a file through Powershell with the default application set up in Windows parameter, just use “Start-process” and the full path of your file
Start-Process "c:\temp\MyExcelFile.xlsx"
In this short example, this command will launch Excel and your file !
You must be logged in to post a comment.