SlideShare a Scribd company logo
• Introduced in 2006
• Implemented as an engine that can be embedded
in a GUI or used directly as a CLI
• Works with modules.
• PowerShell is not just a shell; it is a complete
scripting environment.
• PowerShell Core is the new generation of
PowerShell, it is open source and cross-platform
meaning it could now run on Linux, MacOS, and
Windows!
The ISE enables you to run commands and design, write, test,
and debug scripts in a Windows GUI
Windows
PowerShell
tabs
Script pane
Console pane Add-in
Tools pane
IntelliSense
suggestions
• Verb is the action the cmdlet performs:
• Get
• Set
• New
• Add
• Remove
• Noun is the resource the cmdlet affects:
• Service
• Process
• Prefixes are used to group related nouns:
• AD (Active Directory), SP (SharePoint), AzureAD
• Update-Help utilizes downloadable help content
to update your local Help
• No Help content is distributed with PowerShell
• Get-Help provides quick access to syntax help for
PowerShell commands
• Use –ShowWindow to display help in a floating
window
• Use –Example to quickly jump to usage examples
• Use –Online to display web-based version of help
in your system’s default web browser
• A PSProvider is basically a Windows PowerShell
adapter that makes some form of storage
resemble a disk drive.
• A PSDrive is an actual connection to a form of
storage.
• Run Get-PSDrive for a list
• Run New-PSDrive to map a new drive
• Windows PowerShell runs commands in a pipeline
• In the console, each complete command line is a
pipeline
• Pipelines can contain one or more commands,
with multiple commands separated by a vertical
pipe character (|)
• Commands execute from left to right, with the
output of each command being piped (passed) to
the command after it
• The output of the last command in the pipeline is
what appears on your screen
Get-ADUser –Filter * | Enable-ADAccount Enable
ADAccount
Cmdlet
Get-ADUser
Cmdlet
• The pipeline connects the output from one cmdlet to the
input of another cmdlet
• The combination of the first cmdlet, pipe, and second cmdlet
makes a pipeline
Process
Object
Pipe
Get-Service | Out-File ServiceList.txt
Get-Process | Get-Member
Get-ChildItem –Path C:Windows | Get-Member
Get-Service | Sort Status,Name
Get-Process | Measure-Object
Get-Service | Sort-Object -Property Status | Select-Object –First 10
Get-Service | Select-Object –Property Name,Status
Get-Service | Export-CSV C:TempServices.csv
Get-Service | Where Status –eq Running
Get-Service | Where {$PSItem.Status –eq 'Running' }
Get-Volume | Where {$PSItem.HealthStatus –ne 'Healthy‘ -or
$PSItem.SizeRemaining –lt 100MB }
FOREACH example
Get-ChildItem -Path C:TEMP -file | ForEach-Object LastAccessTime
SET CONTENT example
"One", "Two", "Three", "Four" | Set-Content -Path C:Temptmp.txt
MEASURE OBJECT example
Get-Content C:Temptmp.txt | Measure-Object -Character -Line –Word
List Network connections and categories
Get-NetConnectionProfile
Set network connection to “Private”
Set-NetConnectionProfile -InterfaceIndex <index number> -NetworkCategory
Private
List all services with dependencies on local computer
Get-Service | Where-Object {$_.dependentServices} | Format-List -Property
Name, DependentServices, @{Label="NotDependentServices";
Expression={$_.DependentServices.count}}
List last 20 Events in EventLog
Get-EventLog -Newest 20 -logname "<log name>"
List all Errors in a specified Log
Get-EventLog -LogName <logname> -EntryType Error
Get EventLog from multiple computers
Get-EventLog -LogName "Windows PowerShell" -ComputerName "localhost",
"Server01", "Server02"
List all Events containing a specified word in event description
Get-EventLog -LogName "Application" -Message "*failed*"
Set-ExecutionPolicy Unrestricted
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName
Microsoft.Exchange -ConnectionUri
https://outlook.office365.com/powershell-liveid/ -
Credential $UserCredential -Authentication Basic -
AllowRedirection
Import-PSSession $Session
#Solo analisi
Get-Mailbox -ResultSize 4000 | select
UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAnd
Forward
#Creazione CSV
Get-Mailbox -ResultSize 4000 | select
UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAnd
Forward | Export-csv c:tempOffice365Forwards.csv –
NoTypeInformation
<#
-> Dettagli OU Disabilitate
-> OU Vuote
-> OU Totale
-> Utenti con Nessuna Scadenza Password
-> Links GPO
-> Dettagli GPO
-> Account Inattivi
-> Gruppi con Privilegi Elevati
-> SchemaHistory
-> Stato w32tm2
-> Configurazione w32tm1
-> DC daig
-> Oggetti Computer
#>
# Caricamento Modulo Powershell per Active Directory
try{
Import-Module ActiveDirectory
$Inactivedays = "60" #Inserire il numero di giorni
desiderato
#date
$date = $((Get-Date).ToString('MM-dd-yyyy_hh-mm'))
#path
$path = ".AD_Reports_$date"
if (!(Test-path $path))
{
md $path | Out-Null
}}
catch{
Write-Host “Problema Rilevato durante la creazione della
cartella: $_.Exception.Message "}
Write-Host -ForegroundColor Green "!! Sto recuperando i dati
da Active Directory... !!"
try{
Write-Host "-------------------------------------------------"
Write-Host "Gathering inactive users details..."
Write-Host "-------------------------------------------------"
#Get inactive accounts details
$selection = "EmployeeID", "Name",
"SamAccountName","ObjectSid","ObjectGUID","Enabled",
"UserPrincipalName", "whenChanged", "whenCreated",
"PasswordNeverExpires", "PasswordLastSet", "LastLogonDate",
"lastLogonTimestamp", "DistinguishedName", "Description"
$resultInactive = Search-ADAccount -usersonly -accountinactive
-timespan $Inactivedays
$Inactiveuser = $resultInactive | Get-ADUser -Properties * |
select $selection
$INACount = $Inactiveuser.Count

More Related Content

What's hot

Local development environment evolution
Local development environment evolutionLocal development environment evolution
Local development environment evolutionWise Engineering
 
Powerhsell dsc for chef veterans
Powerhsell dsc for chef veteransPowerhsell dsc for chef veterans
Powerhsell dsc for chef veteransDamien Caro
 
Opscode Webinar: Cooking with Chef on Microsoft Windows
Opscode Webinar: Cooking with Chef on Microsoft WindowsOpscode Webinar: Cooking with Chef on Microsoft Windows
Opscode Webinar: Cooking with Chef on Microsoft WindowsChef Software, Inc.
 
Tips and Tricks for Automating Windows with Chef
Tips and Tricks for Automating Windows with ChefTips and Tricks for Automating Windows with Chef
Tips and Tricks for Automating Windows with ChefChef Software, Inc.
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.xYiguang Hu
 
PowerShell and SharePoint
PowerShell and SharePointPowerShell and SharePoint
PowerShell and SharePointTalbott Crowell
 
Consume wsa
Consume wsaConsume wsa
Consume wsamahe797
 
Cooking with Chef on Windows
Cooking with Chef on WindowsCooking with Chef on Windows
Cooking with Chef on WindowsJulian Dunn
 
Automating That "Other" OS
Automating That "Other" OSAutomating That "Other" OS
Automating That "Other" OSJulian Dunn
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeSarah Z
 
Chef and PowerShell Desired State Configuration
Chef and PowerShell Desired State ConfigurationChef and PowerShell Desired State Configuration
Chef and PowerShell Desired State ConfigurationJulian Dunn
 
Features, Exportables & You
Features, Exportables & YouFeatures, Exportables & You
Features, Exportables & Youjskulski
 
Postman tests in jenkins
Postman tests in jenkinsPostman tests in jenkins
Postman tests in jenkinsAlex Galkin
 
Cooking with Chef on Windows: 2015 Edition
Cooking with Chef on Windows: 2015 EditionCooking with Chef on Windows: 2015 Edition
Cooking with Chef on Windows: 2015 EditionJulian Dunn
 
Serverless forwardjs
Serverless forwardjsServerless forwardjs
Serverless forwardjsUpkar Lidder
 

What's hot (20)

Consul presentation
Consul presentationConsul presentation
Consul presentation
 
Local development environment evolution
Local development environment evolutionLocal development environment evolution
Local development environment evolution
 
Powerhsell dsc for chef veterans
Powerhsell dsc for chef veteransPowerhsell dsc for chef veterans
Powerhsell dsc for chef veterans
 
Opscode Webinar: Cooking with Chef on Microsoft Windows
Opscode Webinar: Cooking with Chef on Microsoft WindowsOpscode Webinar: Cooking with Chef on Microsoft Windows
Opscode Webinar: Cooking with Chef on Microsoft Windows
 
Docker for dev
Docker for devDocker for dev
Docker for dev
 
Tips and Tricks for Automating Windows with Chef
Tips and Tricks for Automating Windows with ChefTips and Tricks for Automating Windows with Chef
Tips and Tricks for Automating Windows with Chef
 
Introduction to Vert.x
Introduction to Vert.xIntroduction to Vert.x
Introduction to Vert.x
 
Pantheon basics
Pantheon basicsPantheon basics
Pantheon basics
 
PowerShell and SharePoint
PowerShell and SharePointPowerShell and SharePoint
PowerShell and SharePoint
 
Consume wsa
Consume wsaConsume wsa
Consume wsa
 
Cooking with Chef on Windows
Cooking with Chef on WindowsCooking with Chef on Windows
Cooking with Chef on Windows
 
FV04_MostoviczT_RAD
FV04_MostoviczT_RADFV04_MostoviczT_RAD
FV04_MostoviczT_RAD
 
Automating That "Other" OS
Automating That "Other" OSAutomating That "Other" OS
Automating That "Other" OS
 
EC2 Container Service
EC2 Container ServiceEC2 Container Service
EC2 Container Service
 
Ansible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less CoffeeAnsible: How to Get More Sleep and Require Less Coffee
Ansible: How to Get More Sleep and Require Less Coffee
 
Chef and PowerShell Desired State Configuration
Chef and PowerShell Desired State ConfigurationChef and PowerShell Desired State Configuration
Chef and PowerShell Desired State Configuration
 
Features, Exportables & You
Features, Exportables & YouFeatures, Exportables & You
Features, Exportables & You
 
Postman tests in jenkins
Postman tests in jenkinsPostman tests in jenkins
Postman tests in jenkins
 
Cooking with Chef on Windows: 2015 Edition
Cooking with Chef on Windows: 2015 EditionCooking with Chef on Windows: 2015 Edition
Cooking with Chef on Windows: 2015 Edition
 
Serverless forwardjs
Serverless forwardjsServerless forwardjs
Serverless forwardjs
 

Similar to CCI2019 - I've got the Power! I've got the Shell!

Windows 2012 R2 Multi Server Management
Windows 2012 R2 Multi Server ManagementWindows 2012 R2 Multi Server Management
Windows 2012 R2 Multi Server ManagementSharkrit JOBBO
 
Power shell training
Power shell trainingPower shell training
Power shell trainingDavid Brabant
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubEssam Salah
 
Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009John Clayton
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellBoulos Dib
 
PowerShell Technical Overview
PowerShell Technical OverviewPowerShell Technical Overview
PowerShell Technical Overviewallandcp
 
Microsoft Offical Course 20410C_04
Microsoft Offical Course 20410C_04Microsoft Offical Course 20410C_04
Microsoft Offical Course 20410C_04gameaxt
 
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdfLearn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdfClapperboardCinemaPV
 
PowerShell for SharePoint Admins
PowerShell for SharePoint AdminsPowerShell for SharePoint Admins
PowerShell for SharePoint AdminsRick Taylor
 
DevOPS training - Day 2/2
DevOPS training - Day 2/2DevOPS training - Day 2/2
DevOPS training - Day 2/2Vincent Mercier
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDmitry Buzdin
 
DevOpsDaysRiga 2017: Dmitry Buzdin - Delivery Pipeline for Windows Machines
DevOpsDaysRiga 2017: Dmitry Buzdin - Delivery Pipeline for Windows MachinesDevOpsDaysRiga 2017: Dmitry Buzdin - Delivery Pipeline for Windows Machines
DevOpsDaysRiga 2017: Dmitry Buzdin - Delivery Pipeline for Windows MachinesDevOpsDays Riga
 
PowerShell Fundamentals
PowerShell FundamentalsPowerShell Fundamentals
PowerShell Fundamentalsmozdzen
 
PowerShellForDBDevelopers
PowerShellForDBDevelopersPowerShellForDBDevelopers
PowerShellForDBDevelopersBryan Cafferky
 
Troubleshooting a XenDesktop Environment using the PowerShell SDK
Troubleshooting a XenDesktop Environment using the PowerShell SDKTroubleshooting a XenDesktop Environment using the PowerShell SDK
Troubleshooting a XenDesktop Environment using the PowerShell SDKDavid McGeough
 
PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2Bryan Cafferky
 

Similar to CCI2019 - I've got the Power! I've got the Shell! (20)

PowerShell-1
PowerShell-1PowerShell-1
PowerShell-1
 
Windows 2012 R2 Multi Server Management
Windows 2012 R2 Multi Server ManagementWindows 2012 R2 Multi Server Management
Windows 2012 R2 Multi Server Management
 
Power shell training
Power shell trainingPower shell training
Power shell training
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge Club
 
Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
PowerShell Technical Overview
PowerShell Technical OverviewPowerShell Technical Overview
PowerShell Technical Overview
 
Windows PowerShell
Windows PowerShellWindows PowerShell
Windows PowerShell
 
Microsoft Offical Course 20410C_04
Microsoft Offical Course 20410C_04Microsoft Offical Course 20410C_04
Microsoft Offical Course 20410C_04
 
PowerShell-2
PowerShell-2PowerShell-2
PowerShell-2
 
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdfLearn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
 
PowerShell for SharePoint Admins
PowerShell for SharePoint AdminsPowerShell for SharePoint Admins
PowerShell for SharePoint Admins
 
DevOPS training - Day 2/2
DevOPS training - Day 2/2DevOPS training - Day 2/2
DevOPS training - Day 2/2
 
Delivery Pipeline for Windows Machines
Delivery Pipeline for Windows MachinesDelivery Pipeline for Windows Machines
Delivery Pipeline for Windows Machines
 
DevOpsDaysRiga 2017: Dmitry Buzdin - Delivery Pipeline for Windows Machines
DevOpsDaysRiga 2017: Dmitry Buzdin - Delivery Pipeline for Windows MachinesDevOpsDaysRiga 2017: Dmitry Buzdin - Delivery Pipeline for Windows Machines
DevOpsDaysRiga 2017: Dmitry Buzdin - Delivery Pipeline for Windows Machines
 
PowerShell Fundamentals
PowerShell FundamentalsPowerShell Fundamentals
PowerShell Fundamentals
 
PowerShellForDBDevelopers
PowerShellForDBDevelopersPowerShellForDBDevelopers
PowerShellForDBDevelopers
 
Troubleshooting a XenDesktop Environment using the PowerShell SDK
Troubleshooting a XenDesktop Environment using the PowerShell SDKTroubleshooting a XenDesktop Environment using the PowerShell SDK
Troubleshooting a XenDesktop Environment using the PowerShell SDK
 
Asp.net tips
Asp.net tipsAsp.net tips
Asp.net tips
 
PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2PowerShell Workshop Series: Session 2
PowerShell Workshop Series: Session 2
 

More from walk2talk srl

CCI 2019 - SQL Injection - Black Hat Vs White Hat
CCI 2019 - SQL Injection - Black Hat Vs White HatCCI 2019 - SQL Injection - Black Hat Vs White Hat
CCI 2019 - SQL Injection - Black Hat Vs White Hatwalk2talk srl
 
CCI 2019 - Exploiting Custom Vision SDK in Python to create an efficient imag...
CCI 2019 - Exploiting Custom Vision SDK in Python to create an efficient imag...CCI 2019 - Exploiting Custom Vision SDK in Python to create an efficient imag...
CCI 2019 - Exploiting Custom Vision SDK in Python to create an efficient imag...walk2talk srl
 
CCI 2019 - Come ottimizzare i propri workload su Azure
CCI 2019 - Come ottimizzare i propri workload su AzureCCI 2019 - Come ottimizzare i propri workload su Azure
CCI 2019 - Come ottimizzare i propri workload su Azurewalk2talk srl
 
CCI 2019 - Exchange 2019 da 0 ad HA in 1 ora
CCI 2019 - Exchange 2019 da 0 ad HA in 1 oraCCI 2019 - Exchange 2019 da 0 ad HA in 1 ora
CCI 2019 - Exchange 2019 da 0 ad HA in 1 orawalk2talk srl
 
CCI 2019 - PowerApps for Enterprise Developers
CCI 2019 - PowerApps for Enterprise DevelopersCCI 2019 - PowerApps for Enterprise Developers
CCI 2019 - PowerApps for Enterprise Developerswalk2talk srl
 
CCI 2019 - Architettare componenti in SPFx, esperienze sul campo
CCI 2019 - Architettare componenti in SPFx, esperienze sul campoCCI 2019 - Architettare componenti in SPFx, esperienze sul campo
CCI 2019 - Architettare componenti in SPFx, esperienze sul campowalk2talk srl
 
CCI 2019 - Step by step come attivare un servizio voce in MS Teams
CCI 2019 - Step by step come attivare un servizio voce in MS TeamsCCI 2019 - Step by step come attivare un servizio voce in MS Teams
CCI 2019 - Step by step come attivare un servizio voce in MS Teamswalk2talk srl
 
CCI 2019 - Strumenti Azure per l'Anomaly Detection in ambito Industria 4.0
CCI 2019 - Strumenti Azure per l'Anomaly Detection in ambito Industria 4.0CCI 2019 - Strumenti Azure per l'Anomaly Detection in ambito Industria 4.0
CCI 2019 - Strumenti Azure per l'Anomaly Detection in ambito Industria 4.0walk2talk srl
 
CCI2019 - Sistema di controllo del traffico con architettura Big Data
CCI2019 - Sistema di controllo del traffico con architettura Big DataCCI2019 - Sistema di controllo del traffico con architettura Big Data
CCI2019 - Sistema di controllo del traffico con architettura Big Datawalk2talk srl
 
CCI2019 - Governance di una Conversational AI
CCI2019 - Governance di una Conversational AICCI2019 - Governance di una Conversational AI
CCI2019 - Governance di una Conversational AIwalk2talk srl
 
CCI2019 - SQL Server ed Azure: Disaster Recovery per tutti
CCI2019 - SQL Server ed Azure: Disaster Recovery per tuttiCCI2019 - SQL Server ed Azure: Disaster Recovery per tutti
CCI2019 - SQL Server ed Azure: Disaster Recovery per tuttiwalk2talk srl
 
CCI2019 - Reagire agli eventi generati dalla propria infrastruttura con Azure...
CCI2019 - Reagire agli eventi generati dalla propria infrastruttura con Azure...CCI2019 - Reagire agli eventi generati dalla propria infrastruttura con Azure...
CCI2019 - Reagire agli eventi generati dalla propria infrastruttura con Azure...walk2talk srl
 
CCI2019 - What's new in Remote Desktop Services on Windows Server 2019 and Azure
CCI2019 - What's new in Remote Desktop Services on Windows Server 2019 and AzureCCI2019 - What's new in Remote Desktop Services on Windows Server 2019 and Azure
CCI2019 - What's new in Remote Desktop Services on Windows Server 2019 and Azurewalk2talk srl
 
CCI2019 - Teams Direct Routing e servizi fonia avanzati
CCI2019 - Teams Direct Routing e servizi fonia avanzatiCCI2019 - Teams Direct Routing e servizi fonia avanzati
CCI2019 - Teams Direct Routing e servizi fonia avanzatiwalk2talk srl
 
CCI2019 - Microservizi: Idee per un'architettura con al centro l'utente
CCI2019 - Microservizi: Idee per un'architettura con al centro l'utenteCCI2019 - Microservizi: Idee per un'architettura con al centro l'utente
CCI2019 - Microservizi: Idee per un'architettura con al centro l'utentewalk2talk srl
 
CCI2019i - Implementare Azure Multi-Factor Authentication Lettere dal Fronte
CCI2019i - Implementare Azure Multi-Factor Authentication Lettere dal FronteCCI2019i - Implementare Azure Multi-Factor Authentication Lettere dal Fronte
CCI2019i - Implementare Azure Multi-Factor Authentication Lettere dal Frontewalk2talk srl
 
CCI2019 - Monitorare SQL Server Senza Andare in Bancarotta
CCI2019 - Monitorare SQL Server Senza Andare in BancarottaCCI2019 - Monitorare SQL Server Senza Andare in Bancarotta
CCI2019 - Monitorare SQL Server Senza Andare in Bancarottawalk2talk srl
 
CCI2019 - Architecting and Implementing Azure Networking
CCI2019 - Architecting and Implementing Azure NetworkingCCI2019 - Architecting and Implementing Azure Networking
CCI2019 - Architecting and Implementing Azure Networkingwalk2talk srl
 
CCI2019 - Teams e lo Shadow IT
CCI2019 - Teams e lo Shadow ITCCI2019 - Teams e lo Shadow IT
CCI2019 - Teams e lo Shadow ITwalk2talk srl
 
CCI2018 - La "moderna" Sicurezza informatica & Microsoft
CCI2018 - La "moderna" Sicurezza informatica & MicrosoftCCI2018 - La "moderna" Sicurezza informatica & Microsoft
CCI2018 - La "moderna" Sicurezza informatica & Microsoftwalk2talk srl
 

More from walk2talk srl (20)

CCI 2019 - SQL Injection - Black Hat Vs White Hat
CCI 2019 - SQL Injection - Black Hat Vs White HatCCI 2019 - SQL Injection - Black Hat Vs White Hat
CCI 2019 - SQL Injection - Black Hat Vs White Hat
 
CCI 2019 - Exploiting Custom Vision SDK in Python to create an efficient imag...
CCI 2019 - Exploiting Custom Vision SDK in Python to create an efficient imag...CCI 2019 - Exploiting Custom Vision SDK in Python to create an efficient imag...
CCI 2019 - Exploiting Custom Vision SDK in Python to create an efficient imag...
 
CCI 2019 - Come ottimizzare i propri workload su Azure
CCI 2019 - Come ottimizzare i propri workload su AzureCCI 2019 - Come ottimizzare i propri workload su Azure
CCI 2019 - Come ottimizzare i propri workload su Azure
 
CCI 2019 - Exchange 2019 da 0 ad HA in 1 ora
CCI 2019 - Exchange 2019 da 0 ad HA in 1 oraCCI 2019 - Exchange 2019 da 0 ad HA in 1 ora
CCI 2019 - Exchange 2019 da 0 ad HA in 1 ora
 
CCI 2019 - PowerApps for Enterprise Developers
CCI 2019 - PowerApps for Enterprise DevelopersCCI 2019 - PowerApps for Enterprise Developers
CCI 2019 - PowerApps for Enterprise Developers
 
CCI 2019 - Architettare componenti in SPFx, esperienze sul campo
CCI 2019 - Architettare componenti in SPFx, esperienze sul campoCCI 2019 - Architettare componenti in SPFx, esperienze sul campo
CCI 2019 - Architettare componenti in SPFx, esperienze sul campo
 
CCI 2019 - Step by step come attivare un servizio voce in MS Teams
CCI 2019 - Step by step come attivare un servizio voce in MS TeamsCCI 2019 - Step by step come attivare un servizio voce in MS Teams
CCI 2019 - Step by step come attivare un servizio voce in MS Teams
 
CCI 2019 - Strumenti Azure per l'Anomaly Detection in ambito Industria 4.0
CCI 2019 - Strumenti Azure per l'Anomaly Detection in ambito Industria 4.0CCI 2019 - Strumenti Azure per l'Anomaly Detection in ambito Industria 4.0
CCI 2019 - Strumenti Azure per l'Anomaly Detection in ambito Industria 4.0
 
CCI2019 - Sistema di controllo del traffico con architettura Big Data
CCI2019 - Sistema di controllo del traffico con architettura Big DataCCI2019 - Sistema di controllo del traffico con architettura Big Data
CCI2019 - Sistema di controllo del traffico con architettura Big Data
 
CCI2019 - Governance di una Conversational AI
CCI2019 - Governance di una Conversational AICCI2019 - Governance di una Conversational AI
CCI2019 - Governance di una Conversational AI
 
CCI2019 - SQL Server ed Azure: Disaster Recovery per tutti
CCI2019 - SQL Server ed Azure: Disaster Recovery per tuttiCCI2019 - SQL Server ed Azure: Disaster Recovery per tutti
CCI2019 - SQL Server ed Azure: Disaster Recovery per tutti
 
CCI2019 - Reagire agli eventi generati dalla propria infrastruttura con Azure...
CCI2019 - Reagire agli eventi generati dalla propria infrastruttura con Azure...CCI2019 - Reagire agli eventi generati dalla propria infrastruttura con Azure...
CCI2019 - Reagire agli eventi generati dalla propria infrastruttura con Azure...
 
CCI2019 - What's new in Remote Desktop Services on Windows Server 2019 and Azure
CCI2019 - What's new in Remote Desktop Services on Windows Server 2019 and AzureCCI2019 - What's new in Remote Desktop Services on Windows Server 2019 and Azure
CCI2019 - What's new in Remote Desktop Services on Windows Server 2019 and Azure
 
CCI2019 - Teams Direct Routing e servizi fonia avanzati
CCI2019 - Teams Direct Routing e servizi fonia avanzatiCCI2019 - Teams Direct Routing e servizi fonia avanzati
CCI2019 - Teams Direct Routing e servizi fonia avanzati
 
CCI2019 - Microservizi: Idee per un'architettura con al centro l'utente
CCI2019 - Microservizi: Idee per un'architettura con al centro l'utenteCCI2019 - Microservizi: Idee per un'architettura con al centro l'utente
CCI2019 - Microservizi: Idee per un'architettura con al centro l'utente
 
CCI2019i - Implementare Azure Multi-Factor Authentication Lettere dal Fronte
CCI2019i - Implementare Azure Multi-Factor Authentication Lettere dal FronteCCI2019i - Implementare Azure Multi-Factor Authentication Lettere dal Fronte
CCI2019i - Implementare Azure Multi-Factor Authentication Lettere dal Fronte
 
CCI2019 - Monitorare SQL Server Senza Andare in Bancarotta
CCI2019 - Monitorare SQL Server Senza Andare in BancarottaCCI2019 - Monitorare SQL Server Senza Andare in Bancarotta
CCI2019 - Monitorare SQL Server Senza Andare in Bancarotta
 
CCI2019 - Architecting and Implementing Azure Networking
CCI2019 - Architecting and Implementing Azure NetworkingCCI2019 - Architecting and Implementing Azure Networking
CCI2019 - Architecting and Implementing Azure Networking
 
CCI2019 - Teams e lo Shadow IT
CCI2019 - Teams e lo Shadow ITCCI2019 - Teams e lo Shadow IT
CCI2019 - Teams e lo Shadow IT
 
CCI2018 - La "moderna" Sicurezza informatica & Microsoft
CCI2018 - La "moderna" Sicurezza informatica & MicrosoftCCI2018 - La "moderna" Sicurezza informatica & Microsoft
CCI2018 - La "moderna" Sicurezza informatica & Microsoft
 

Recently uploaded

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxAbida Shariff
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsPaul Groth
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Product School
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupCatarinaPereira64715
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlPeter Udo Diehl
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀DianaGray10
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...Elena Simperl
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Thierry Lestable
 

Recently uploaded (20)

Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
Exploring UiPath Orchestrator API: updates and limits in 2024 🚀
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 

CCI2019 - I've got the Power! I've got the Shell!

  • 1.
  • 2.
  • 3. • Introduced in 2006 • Implemented as an engine that can be embedded in a GUI or used directly as a CLI • Works with modules. • PowerShell is not just a shell; it is a complete scripting environment. • PowerShell Core is the new generation of PowerShell, it is open source and cross-platform meaning it could now run on Linux, MacOS, and Windows!
  • 4. The ISE enables you to run commands and design, write, test, and debug scripts in a Windows GUI Windows PowerShell tabs Script pane Console pane Add-in Tools pane IntelliSense suggestions
  • 5. • Verb is the action the cmdlet performs: • Get • Set • New • Add • Remove • Noun is the resource the cmdlet affects: • Service • Process • Prefixes are used to group related nouns: • AD (Active Directory), SP (SharePoint), AzureAD
  • 6. • Update-Help utilizes downloadable help content to update your local Help • No Help content is distributed with PowerShell • Get-Help provides quick access to syntax help for PowerShell commands • Use –ShowWindow to display help in a floating window • Use –Example to quickly jump to usage examples • Use –Online to display web-based version of help in your system’s default web browser
  • 7. • A PSProvider is basically a Windows PowerShell adapter that makes some form of storage resemble a disk drive. • A PSDrive is an actual connection to a form of storage. • Run Get-PSDrive for a list • Run New-PSDrive to map a new drive
  • 8. • Windows PowerShell runs commands in a pipeline • In the console, each complete command line is a pipeline • Pipelines can contain one or more commands, with multiple commands separated by a vertical pipe character (|) • Commands execute from left to right, with the output of each command being piped (passed) to the command after it • The output of the last command in the pipeline is what appears on your screen
  • 9. Get-ADUser –Filter * | Enable-ADAccount Enable ADAccount Cmdlet Get-ADUser Cmdlet • The pipeline connects the output from one cmdlet to the input of another cmdlet • The combination of the first cmdlet, pipe, and second cmdlet makes a pipeline Process Object Pipe
  • 10. Get-Service | Out-File ServiceList.txt Get-Process | Get-Member Get-ChildItem –Path C:Windows | Get-Member Get-Service | Sort Status,Name Get-Process | Measure-Object Get-Service | Sort-Object -Property Status | Select-Object –First 10 Get-Service | Select-Object –Property Name,Status Get-Service | Export-CSV C:TempServices.csv Get-Service | Where Status –eq Running Get-Service | Where {$PSItem.Status –eq 'Running' } Get-Volume | Where {$PSItem.HealthStatus –ne 'Healthy‘ -or $PSItem.SizeRemaining –lt 100MB }
  • 11. FOREACH example Get-ChildItem -Path C:TEMP -file | ForEach-Object LastAccessTime SET CONTENT example "One", "Two", "Three", "Four" | Set-Content -Path C:Temptmp.txt MEASURE OBJECT example Get-Content C:Temptmp.txt | Measure-Object -Character -Line –Word List Network connections and categories Get-NetConnectionProfile Set network connection to “Private” Set-NetConnectionProfile -InterfaceIndex <index number> -NetworkCategory Private
  • 12. List all services with dependencies on local computer Get-Service | Where-Object {$_.dependentServices} | Format-List -Property Name, DependentServices, @{Label="NotDependentServices"; Expression={$_.DependentServices.count}} List last 20 Events in EventLog Get-EventLog -Newest 20 -logname "<log name>" List all Errors in a specified Log Get-EventLog -LogName <logname> -EntryType Error Get EventLog from multiple computers Get-EventLog -LogName "Windows PowerShell" -ComputerName "localhost", "Server01", "Server02" List all Events containing a specified word in event description Get-EventLog -LogName "Application" -Message "*failed*"
  • 13. Set-ExecutionPolicy Unrestricted $UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ - Credential $UserCredential -Authentication Basic - AllowRedirection Import-PSSession $Session #Solo analisi Get-Mailbox -ResultSize 4000 | select UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAnd Forward #Creazione CSV Get-Mailbox -ResultSize 4000 | select UserPrincipalName,ForwardingSmtpAddress,DeliverToMailboxAnd Forward | Export-csv c:tempOffice365Forwards.csv – NoTypeInformation
  • 14. <# -> Dettagli OU Disabilitate -> OU Vuote -> OU Totale -> Utenti con Nessuna Scadenza Password -> Links GPO -> Dettagli GPO -> Account Inattivi -> Gruppi con Privilegi Elevati -> SchemaHistory -> Stato w32tm2 -> Configurazione w32tm1 -> DC daig -> Oggetti Computer #>
  • 15. # Caricamento Modulo Powershell per Active Directory try{ Import-Module ActiveDirectory $Inactivedays = "60" #Inserire il numero di giorni desiderato #date $date = $((Get-Date).ToString('MM-dd-yyyy_hh-mm')) #path $path = ".AD_Reports_$date" if (!(Test-path $path)) { md $path | Out-Null }} catch{ Write-Host “Problema Rilevato durante la creazione della cartella: $_.Exception.Message "}
  • 16. Write-Host -ForegroundColor Green "!! Sto recuperando i dati da Active Directory... !!" try{ Write-Host "-------------------------------------------------" Write-Host "Gathering inactive users details..." Write-Host "-------------------------------------------------" #Get inactive accounts details $selection = "EmployeeID", "Name", "SamAccountName","ObjectSid","ObjectGUID","Enabled", "UserPrincipalName", "whenChanged", "whenCreated", "PasswordNeverExpires", "PasswordLastSet", "LastLogonDate", "lastLogonTimestamp", "DistinguishedName", "Description" $resultInactive = Search-ADAccount -usersonly -accountinactive -timespan $Inactivedays $Inactiveuser = $resultInactive | Get-ADUser -Properties * | select $selection $INACount = $Inactiveuser.Count

Editor's Notes

  1. Show PS Version info $PSVersionTable Rilasciato inizialmente per gestire Exchange 2007 – exchange management shell PowerShell è una vera e propria shell a riga di comando pensata e strutturata per lo scripting e l’amministrazione di sistema basata su .Net Framework.... Note: Microsoft intendeva in origine rilasciare PowerShell insieme con Vista, ma in seguito ha definito delle date di rilascio diverse per PowerShell. La versione 1.0 è stata rilasciata il 14 novembre 2006. La versione 2.0 è presente di serie su Windows 7. La versione 3.0 è di serie su Windows 8 e Windows Server 2012. La versione 4.0 è di serie su Windows 8.1 e Windows Server 2012 R2 La versione 5.0 è di serie su Windows 10 e Windows Server 2016 TP La versione 5.1 Windows Management Framework (WMF) 5.1 and is included in Windows Server 2016 and Windows 10 Anniversary Edition (1607) You can install Windows PowerShell 5.1 on all the operating systems that you can install Windows PowerShell 5.0 on. To do so, you can download and install the Windows Management Framework 5.1 from the Windows Download Center
  2. New-PSDrive –Name WINDIR –Root C:\Windows –PSProvider FileSystem
  3. Descrivere la slide ANIMATA... Note: I dati in una pipeline sono assegnati ad una speciale variabile denominata $PSItem (nelle versioni vecchie $_ ) che esiste unicamente fintantoche la pipeline è in esecuzione. -Filter è un parametro obbligatorio che filtra i risultati (con * visualizza tutto)
  4. Script per verificare forwarders email
  5. PowerShell uses the ! character as an alias for the logical -not operator: PowerShell interprets everything that is empty, $Null, or 0 to the Boolean $False. Bool can only have $True or $False. By casting the value to a Boolean you can see what PowerShell interprets for each value: [bool]0 # False [bool]1 # True [bool]"" # False [bool]"test" # True [bool]$null # False The locical NOT operation turns each Boolean into its opposite: !$True # Is $False !$False # Is $True ![bool]0 # True ![bool]1 # False ![bool]"" # True ![bool]"test" # False ![bool]$null # True