Sometimes it becomes necessary to extract the command name from a command line. Here is a function that can do this: And this is the code: function...
posts-powershell
Categories
- Free tools
- SQL Admin Toolset
- SQL Compliance Manager
- SQL Defrag Manager
- SQL Diagnostic Manager for MySQL
- SQL Diagnostic Manager for SQL Server
- SQL Diagnostic Manager Pro
- SQL Doctor
- SQL Enterprise Job Manager
- SQL Inventory Manager
- SQL Query Tuner for SQL Server
- SQL Safe Backup
- SQL Secure
- SQL Workload Analysis for SQL Server
- Uptime Infrastructure Monitor Formerly Uptime
Tags
Administration agent-based monitoring Agentless Monitoring alert responses alert thresholds alerting Alerts Amazon Aurora Amazon EC2 Amazon RDS Amazon RDS / Aurora Amazon RDS for SQL Server Amazon Redshift Amazon S3 Amazon Web Services (AWS) Analytics application monitoring Aqua Data Studio automation availability Azure Azure SQL Database azure sql managed instance Azure VM backup Backup and recovery backup and restore backup compression backup status Backup Strategy backups big data Blocking bug fixes business architecture business data objects business intelligence business process modeling business process models capacity planning change management cloud cloud database cloud database monitoring cloud infrastructure cloud migration cloud providers Cloud Readiness Cloud Services cloud storage cloud virtual machine cloud VM clusters code completion collaboration compliance compliance audit compliance audits compliance manager compliance reporting conference configuration connect to database cpu Cross Platform custom counters Custom Views customer survey customer testimonials Dark Theme dashboards data analysis Data Analytics data architect data architecture data breaches Data Collector data governance data lakes data lineage data management data model data modeler data modeling data models data privacy data protection data security data security measures data sources data visualization data warehouse database database administration database administrator database automation database backup database backups database capacity database changes database community database connection database design database developer database developers database development database diversity Database Engine Tuning Advisor database fragmentation database GUI database IDE database indexes database inventory management database locks database management database migration database monitoring database navigation database optimization database performance Database Permissions database platforms database profiling database queries database recovery database replication database restore database schema database security database support database synchronization database tools database transactions database tuning database-as-a-service databases DB Change Manager DB Optimizer DB PowerStudio DB2 DBA DBaaS DBArtisan dBase DBMS DDL Debugging defragmentation Demo diagnostic manager diagnostics dimensional modeling disaster recovery Download drills embedded database Encryption End-user Experience entity-relationship model ER/Studio ER/Studio Data Architect ER/Studio Enterprise Team Edition events execution plans free tools galera cluster GDPR Getting Started Git GitHub Google Cloud Hadoop Healthcare high availability HIPAA Hive hybrid clouds Hyper-V IDERA IDERA ACE Index Analyzer index optimization infrastructure as a service (IaaS) infrastructure monitoring installation Integrated Development Environment interbase Inventory Manager IT infrastructure Java JD Edwards JSON licensing load test load testing logical data model macOS macros managed cloud database managed cloud databases MariaDB memory memorystorage memoryusage metadata metric baselines metric thresholds Microsoft Azure Microsoft Azure SQL Database Microsoft PowerShell Microsoft SQL Server Microsoft Windows MongoDB monitoring Monitoring Tools Monyog multiple platforms MySQL news newsletter NoSQL Notifications odbc optimization Oracle PeopleSoft performance Performance Dashboards performance metrics performance monitoring performance schema performance tuning personally identifiable information physical data model Platform platform as a service (PaaS) PostgreSQL Precise Precise for Databases Precise for Oracle Precise for SQL Server Precise Management Database (PMDB) product updates Project Migration public clouds Query Analyzer query builder query monitor query optimization query performance Query Store query tool query tuning query-level waits Rapid SQL rdbms real time monitoring Real User Monitoring recovery regulations relational databases Releases Reporting Reports repository Restore reverse engineering Roadmap sample SAP Scalability Security Policy Security Practices server monitoring Server performance server-level waits Service Level Agreement SkySQL slow query SNMP snowflake source control SQL SQL Admin Toolset SQL CM SQL code SQL coding SQL Compliance Manager SQL Defrag Manager sql development SQL Diagnostic Manager SQL Diagnostic Manager for MySQL SQL Diagnostic Manager for SQL Server SQL Diagnostic Manager Pro SQL DM SQL Doctor SQL Enterprise Job Manager SQl IM SQL Inventory Manager SQL Management Suite SQL Monitoring SQL Performance SQL Quality SQL query SQL Query Tuner SQL Safe Backup SQL script SQL Secure SQL Security Suite SQL Server sql server alert SQL Server Migration SQL Server Performance SQL Server Recommendations SQL Server Security SQL statement history SQL tuning SQL Virtual Database sqlmemory sqlserver SQLyog Storage Storage Performance structured data Subversion Support tempdb tempdb data temporal data Tips and Tricks troubleshooting universal data models universal mapping unstructured data Uptime Infrastructure Monitor user experience user permissions Virtual Machine (VM) web services webinar What-if analysis WindowsPowerShellOpen MsgBox with Random Sound
You may have seen script code that opens a MsgBox dialog box. Today, you get a piece of code that opens a MsgBox and plays a random sound, adding...
Automatically Downloading Pictures via Google Picture Search
In a previous tip you learned how you can use Invoke-WebRequest to get image links from Google Image Search. Invoke-WebRequest can do better,...
Getting Picture URLs from Google Picture Search
Invoke-WebRequest is your friend whenever you want to download information from the Internet. You could, for example, send a search request to...
Finding Registered Event Sources
Each Windows log file has a list of registered event sources. To find out which event sources are registered to which event log, you can directly...
IntelliSense Trick to Show Variables
In the PowerShell ISE editor, when you enter a dollar sign, an IntelliSense menu opens and displays all variables that are currently defined. When...
Writing Events to Own Event Logs
Often, there is a need to log information when a script runs. Instead of writing log information to a text file that you would have to maintain and...
Logging All Errors
In a previous tip you have seen that cmdlet errors can only be caught by an error handler if the -ErrorAction is set to "Stop". Doing this...
Catching Non-Terminating Errors
Non-terminating errors are errors that are handled by a cmdlet internally. Most errors that can occur in cmdlets are non-terminating. You cannot...
Hiding Terminating Errors
Occasionally, you may have noticed that cmdlets throw errors although you specified "SilentlyContinue" as -ErrorAction. The -ErrorAction...
Getting Events From All Event Logs
Recently, a reader asked how to retrieve all events from all event logs from a local or remote system, and optionally save them to file. Here is a...
Running Background Jobs Efficiently
Using background jobs to run tasks concurrently often is not very efficient as you might have seen in a previous tip. Background job performance...
Parallel Processing in PowerShell
If a script needs some speed-up, you might find background jobs helpful. They can be used if a script does a number of things that also could run...
Converting Ticks into Real Date
Internally, Active Directory uses ticks (100 nanosecond units since 1601) to represent date and time. It has been hard in the past to convert these...
Logging Script Runtime
If you'd like to monitor how long a script takes to run, you could use Measure-Command, but this cmdlet is for diagnostic purposes only and...
Fixing Encoding for Excel CSV
When you save Microsoft Excel data as CSV, unfortunately the encoding does not match the default encoding used by Import-Csv. So when you import the...
Reading All Text
You can use Get-Content to read in any plain text file. However, Get-Content will return the file content line by line, and you get back a string...
Storing Secret Data
If you wanted to store sensitive data in a way that only you could retrieve it, you can use a funny approach: convert some plain text into a secure...
Using Encrypting File System (EFS) to Protect Passwords
If you absolutely need to hardcode passwords and other secrets into your scripts (which you should avoid for obvious reasons), then you might still...
Testing UNC Paths
Test-Path can test whether or not a given file or folder exists. This works fine for paths that use a drive letter, but can fail with pure UNC...
Enabling PowerShell Remoting
If you'd like to use PowerShell Remoting to execute commands and scripts on another machine, then you need to enable Remoting on the target side...
Enabling Classic Remoting
Many cmdlets have built-in remoting capabilities, for example Get-Service and Get-Process both have the parameter -ComputerName, and so does...
Exporting and Importing Credentials in PowerShell
Credential objects contain a username and a password. You can create them using Get-Credential, and then supply this object to any cmdlet that has...
Finding USB Stick Information
Did you know that Windows logs any USB stick type you ever used? To get that information from the Registry, simply use this function: function...
Finding Time Servers (And Reading All RegKey Values)
Maybe you'd like to get a list of timeservers registered in the Registry database. Then you probably run code like this: Get-ItemProperty -Path...
Finding Expired Certificates
PowerShell grants access to your certificate stores by using the cert: drive. You can use this drive to find certificates based on given criteria....
Submitting Arguments to EXE Files
Running applications such as robocopy.exe from PowerShell sometimes is not trivial. How do you submit arguments to the EXE so that PowerShell...
Applying NTFS Access Rules
There are many ways to add or change NTFS permissions. One is to reuse existing tools such as icacls.exe. This function will create new folders that...
Profiling Systems
If you just want to profile a local or remote system and get back the most commonly used pieces of information, then do not waste time for your own...
Running Commands Elevated in PowerShell
Sometimes, a script may need to run a command that needs elevation (Administrator privileges). Instead of requiring the script to run with full...