Issue
Code backup
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
$Today = (Get-Date).DateTime
|
||||
|
||||
$Hello = 'Hello World!'
|
||||
$Senza = 'Senza Write Host'
|
||||
|
||||
Write-Host $Hello
|
||||
Write-Host $Today
|
||||
|
||||
$Senza
|
||||
|
||||
# $null eliminare una variabile
|
||||
$Senza = $null
|
||||
|
||||
$Senza
|
||||
@@ -0,0 +1,13 @@
|
||||
#Read Host
|
||||
|
||||
#function getUsername {
|
||||
# param ([string]
|
||||
# $name = (
|
||||
# Read-Host 'Inserisci il tuo nome:'
|
||||
# )
|
||||
# )
|
||||
# Write-Host 'Benvenuto $name'
|
||||
#}
|
||||
|
||||
$name = Read-Host 'Inserisci il tuo nome'
|
||||
Write-Host 'Benvenuto', $name, '!'
|
||||
@@ -0,0 +1,6 @@
|
||||
Get-ADDomain | Select-Object InfrastructureMaster, RIDMaster, PDCEmulator
|
||||
Get-ADForest | Select-Object DomainNamingMaster, SchemaMaster
|
||||
Get-ADDomainController -Filter * |
|
||||
Select-Object Name, Domain, Forest, OperationMasterRoles |
|
||||
Where-Object {$_.OperationMasterRoles} |
|
||||
Format-Table -AutoSize
|
||||
@@ -0,0 +1,27 @@
|
||||
function Show-Menu {
|
||||
param (
|
||||
[string]$Title = 'My Menu'
|
||||
)
|
||||
Clear-Host
|
||||
Write-Host "================ $Title ================"
|
||||
|
||||
Write-Host "1: Press '1' for this option."
|
||||
Write-Host "2: Press '2' for this option."
|
||||
Write-Host "3: Press '3' for this option."
|
||||
Write-Host "Q: Press 'Q' to quit."
|
||||
} do {
|
||||
Show-Menu
|
||||
$selection = Read-Host "Please make a selection"
|
||||
switch ($selection)
|
||||
{
|
||||
'1' {
|
||||
'You chose option #1'
|
||||
} '2' {
|
||||
'You chose option #2'
|
||||
} '3' {
|
||||
'You chose option #3'
|
||||
}
|
||||
}
|
||||
pause
|
||||
}
|
||||
until ($selection -eq 'q')
|
||||
@@ -0,0 +1 @@
|
||||
1..254 | ForEach-Object {Test-Connection -ComputerName "172.16.83.$_" -Count 1 -ErrorAction:SilentlyContinue -AsJob} | Get-Job | Receive-Job -Wait -AutoRemoveJob | Where-Object {$_.StatusCode -eq 0} | Select-Object -Property Address
|
||||
@@ -0,0 +1,22 @@
|
||||
$EmailFrom = "no-replay@pal.it"
|
||||
$Subject = "PAL SRL - BUONI CARBURANTE Q8"
|
||||
|
||||
$EmailTo = "claudio.boggian00@gmail.com"
|
||||
|
||||
$Body = "Buongiorno,
|
||||
|
||||
a seguito della decisione aziendale di erogare il 'bonus benzina' secondo la possibilità data dall’art. 1 del DL n. 5 del 2023 (Decreto carburanti), con la presente invio in allegato il file pdf contenente i buoni carburante Q8.
|
||||
|
||||
I buoni potranno essere presentati in cassa (da smartphone o stampati) oppure utilizzati digitando il codice di 26 cifre nella colonnina del distributore self-service, selezionando la voce 'utilizza codice'.
|
||||
Cordiali saluti,
|
||||
PAL s.r.l."
|
||||
|
||||
$SMTPMessage = New-Object System.Net.Mail.MailMessage($EmailFrom,$EmailTo,$Subject,$Body)
|
||||
|
||||
$SMTPClient = New-Object Net.Mail.SmtpClient("paldocker01.pal.local", 25)
|
||||
|
||||
$SMTPClient.Send($SMTPMessage)
|
||||
|
||||
LogWrite("Send mail to $EmailTo with $FilePath1")
|
||||
|
||||
Write-Host("Send mail to $EmailTo") -ForegroundColor Green
|
||||
@@ -0,0 +1,41 @@
|
||||
$ArNames1 = @("Hakeem Drake", "Bill Kimble", "Dejon Howard", "Lazaro Klinger", "Madilynn Nunn", "Melanie Bandy", "Maribel Purvis", "Willis Meeks", "Maryann Burk", "Breeanna Goldman", "Lazagerro Klin")
|
||||
$ArRev1 = @("B","F","U","D","G","E","K","N","K","O","")
|
||||
|
||||
$objs = $null
|
||||
|
||||
$ArNames2 = @("Hakeem Drake", "Bill Kimble", "Dejon Howard", "Lazaro Klinger", "Melanie Bandy", "Maribel Purvis", "Willis Meeks", "Maryann Burk", "Breeanna Goldman", "Maribel Nim")
|
||||
$ArRev2 = @("B","F","U","R","G","E","K","J","K","O")
|
||||
|
||||
|
||||
|
||||
|
||||
if($ArNames1.Count -eq $ArRev1.Count){
|
||||
for ($i = 0; $i -lt $ArNames1.Count; $i++) {
|
||||
|
||||
$sp = $ArNames2.IndexOf($ArNames1[$i])
|
||||
|
||||
if($sp -lt 0){
|
||||
$objs += @(New-Object -TypeName PSObject -Property @{
|
||||
Name = $ArNames1[$i]
|
||||
RevA = $ArRev1[$i]
|
||||
Eq = "missing"
|
||||
})
|
||||
}
|
||||
else{
|
||||
|
||||
$eq = $ArRev1[$i].Equals($ArRev2[$sp])
|
||||
|
||||
$objs += @(New-Object -TypeName PSObject -Property @{
|
||||
|
||||
Name = $ArNames1[$i]
|
||||
RevA = $ArRev1[$i]
|
||||
RevB = $ArRev2[$sp]
|
||||
Eq = $eq
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$objs | Select-Object Name, RevA, RevB, Eq
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
$e = @(
|
||||
"pipplo a pluto",
|
||||
"pipplo b pluto0",
|
||||
"pipplo c pluto",
|
||||
"pipplo a pluto",
|
||||
"pipplo b pluto1",
|
||||
"pipplo a pluto",
|
||||
"pipplo a pluto",
|
||||
"pipplo a pluto",
|
||||
"pipplo b pluto2",
|
||||
"pipplo a pluto",
|
||||
"pipplo b pluto3",
|
||||
"pipplo a pluto"
|
||||
)
|
||||
|
||||
foreach($s in $e)
|
||||
{
|
||||
if ($s -Match " b ") {
|
||||
Write-Output $s
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
Invoke-Command -ComputerName PC179 -ScriptBlock {
|
||||
Get-ciminstance -class SoftwareLicensingProduct |
|
||||
where {$_.name -match ‘Office 16, Office16O365HomePremR_Subscription5’ -AND $_.licensefamily} |
|
||||
format-list -property Name, Description, `
|
||||
@{Label=”Grace period (days)”; Expression={ $_.graceperiodremaining / 1440}}, `
|
||||
@{Label= “License Status”; Expression={switch (foreach {$_.LicenseStatus}) `
|
||||
{ 0 {“Unlicensed”} `
|
||||
1 {“Licensed”} `
|
||||
2 {“Out-Of-Box Grace Period”} `
|
||||
3 {“Out-Of-Tolerance Grace Period”} `
|
||||
4 {“Non-Genuine Grace Period”} `
|
||||
} } }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
Get-ciminstance -class SoftwareLicensingProduct |
|
||||
where {$_.name -match ‘Office 16, Office16O365HomePremR_Subscription5’ -AND $_.licensefamily} |
|
||||
format-list -property Name, Description, `
|
||||
@{Label=”Grace period (days)”; Expression={ $_.graceperiodremaining / 1440}}, `
|
||||
@{Label= “License Status”; Expression={switch (foreach {$_.LicenseStatus}) `
|
||||
{ 0 {“Unlicensed”} `
|
||||
1 {“Licensed”} `
|
||||
2 {“Out-Of-Box Grace Period”} `
|
||||
3 {“Out-Of-Tolerance Grace Period”} `
|
||||
4 {“Non-Genuine Grace Period”} `
|
||||
} } }
|
||||
@@ -0,0 +1,13 @@
|
||||
$app = 'PS - User Catch'
|
||||
$ver = 'v 0.0'
|
||||
|
||||
Write-Host $app, $ver,"`n Sweep Ip start"
|
||||
|
||||
$sweepip = (190..202) | % {
|
||||
$ip="172.16.82.$_";
|
||||
Write-output "$IP `t` $(test-connection -computername "$ip" -quiet -count 1) `t` $(Resolve-DnsName $ip -ErrorAction Ignore |select -exp NameHost)`n"
|
||||
}
|
||||
|
||||
#$userquery = query user /server:$pippo
|
||||
|
||||
Write-Host $sweepip
|
||||
@@ -0,0 +1,29 @@
|
||||
$app = 'PS - User Catch'
|
||||
$ver = 'v 0.1'
|
||||
|
||||
Write-Host $app, $ver,"`n UserCatch"
|
||||
|
||||
$SweepIp = (193..198) | % {
|
||||
$Ip="172.16.82.$_";
|
||||
$Status=test-connection -computername "$ip" -quiet -count 1;
|
||||
|
||||
$StatusOut = switch ($Status) {
|
||||
'True' {"True"}
|
||||
'False' {"`0"}
|
||||
}
|
||||
|
||||
$GetHostname=Resolve-DnsName $ip -ErrorAction Ignore |select -exp NameHost;
|
||||
|
||||
$QueryUser=if ($StatusOut -like 'True'){
|
||||
if ($GetHostname -like 'PC*'){
|
||||
(query user /server:$GetHostname) -split "`n" -replace '\s\s+', ';' | convertfrom-csv -Delimiter ';'
|
||||
}
|
||||
}
|
||||
|
||||
Write-output "`n$IP `t $StatusOut `t $GetHostname"
|
||||
if ($GetHostname -like 'PC*'){
|
||||
Write-Output "`n$QueryUser"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host $SweepIp
|
||||
@@ -0,0 +1,43 @@
|
||||
$app = "PS - User Catch"
|
||||
$ver = "v 0.2"
|
||||
|
||||
$start = "Stai eseguendo:"
|
||||
$exec = "Lo script $app e' in esecuzione."
|
||||
|
||||
Write-Host $start, $app, $ver, "`n$exec"
|
||||
|
||||
$UserCatch = (173..176) | % {
|
||||
$Ip = "172.16.91.$_";
|
||||
$Status = test-connection -computername "$ip" -quiet -count 1;
|
||||
|
||||
$StatusOut = switch ($Status) {
|
||||
'True' {"True"}
|
||||
'False' {"`0"}
|
||||
}
|
||||
|
||||
$GetHostname = Resolve-DnsName $ip -ErrorAction Ignore |select -exp NameHost;
|
||||
|
||||
$QueryUser = if ($GetHostname -like 'PC*'){
|
||||
foreach ($s in $GetHostname) #For Each Server
|
||||
{
|
||||
foreach($ServerLine in @(query user /server:$s) -split "\n") #Each Server Line
|
||||
{
|
||||
#USERNAME SESSIONNAME ID STATE IDLE TIME LOGON TIME
|
||||
|
||||
$Parsed_Server = $ServerLine -split "\s+"
|
||||
|
||||
$Parsed_Server[1] #USERNAME
|
||||
$Parsed_Server[4] #STATE
|
||||
$Parsed_Server[6] #LOGON TIME
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-output "`n$IP`t$StatusOut`t$GetHostname"
|
||||
|
||||
if ($GetHostname -like 'PC*'){
|
||||
Write-Output "`n$QueryUser`n"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host $UserCatch
|
||||
@@ -0,0 +1,51 @@
|
||||
$app = "PS - User Catch"
|
||||
$ver = "v 0.3"
|
||||
|
||||
$start = "Stai eseguendo:"
|
||||
$exec = "Lo script $app e' in esecuzione."
|
||||
|
||||
Write-Host $start, $app, $ver
|
||||
Write-Host $exec -fore green
|
||||
|
||||
$UserCatch = (180..200) | % {
|
||||
$Ip = "172.16.82.$_";
|
||||
$Status = test-connection -computername "$ip" -quiet -count 1;
|
||||
|
||||
$StatusOut = switch ($Status) {
|
||||
'True' {"True"}
|
||||
'False' {"`0"}
|
||||
}
|
||||
|
||||
if ($Status -like 'True') {
|
||||
|
||||
$GetHostname = Resolve-DnsName $ip -ErrorAction Ignore |select -exp NameHost;
|
||||
|
||||
$QueryUser = if ($GetHostname -like 'PC*') {
|
||||
foreach ($s in $GetHostname){
|
||||
foreach($ServerLine in @(query user /server:$s) -split"\n")
|
||||
{
|
||||
$Parsed_Server = $ServerLine -split"\s+"
|
||||
|
||||
$Parsed_Server[1]
|
||||
$Parsed_Server[4]
|
||||
$Parsed_Server[6]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-output "`n$IP`t$StatusOut`t$GetHostname"
|
||||
|
||||
if ($GetHostname -like 'PC*') {
|
||||
Write-Output "`n$QueryUser`n"
|
||||
}
|
||||
}
|
||||
else {
|
||||
"`0"
|
||||
}
|
||||
}
|
||||
|
||||
Start-Transcript -Path .\testlog.txt
|
||||
|
||||
Write-Host $UserCatch
|
||||
|
||||
Stop-Transcript
|
||||
@@ -0,0 +1,69 @@
|
||||
$app = "PS - UserCatch"
|
||||
$ver = "v 0.4"
|
||||
|
||||
$start = "Stai eseguendo:"
|
||||
$exec = "Lo script $app e' in esecuzione."
|
||||
|
||||
Write-Host $start, $app, $ver
|
||||
Write-Host $exec -fore green
|
||||
|
||||
$UserCatch = (1..254) | % {
|
||||
$Ip = "172.16.94.$_";
|
||||
$Status = test-connection -computername "$ip" -quiet -count 1;
|
||||
|
||||
$StatusOut = switch ($Status) {
|
||||
'True' {"True"}
|
||||
'False' {"`0"}
|
||||
}
|
||||
|
||||
if ($Status -like 'True') {
|
||||
|
||||
$GetHostname = Resolve-DnsName $ip -ErrorAction Ignore | select -exp NameHost;
|
||||
|
||||
$QueryUser = if ($GetHostname -like 'PC*') {
|
||||
foreach ($s in $GetHostname){
|
||||
foreach($ServerLine in @(query user /server:$s) -split"\n")
|
||||
{
|
||||
$Parsed_Server = $ServerLine -split"\s+"
|
||||
|
||||
$Parsed_Server[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$QueryState = if ($GetHostname -like 'PC*') {
|
||||
foreach ($s in $GetHostname){
|
||||
foreach($ServerLine in @(query user /server:$s) -split"\n")
|
||||
{
|
||||
$Parsed_Server = $ServerLine -split"\s+"
|
||||
|
||||
$Parsed_Server[4]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$QueryLogon = if ($GetHostname -like 'PC*') {
|
||||
foreach ($s in $GetHostname){
|
||||
foreach($ServerLine in @(query user /server:$s) -split"\n")
|
||||
{
|
||||
$Parsed_Server = $ServerLine -split"\s+"
|
||||
|
||||
$Parsed_Server[6]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-output "`n$IP`t$GetHostname"
|
||||
|
||||
if ($GetHostname -like 'PC*') {
|
||||
Write-Output "`n`n$QueryUser"
|
||||
Write-Output "`n$QueryState"
|
||||
Write-Output "`n$QueryLogon`n"
|
||||
}
|
||||
}
|
||||
else {
|
||||
"`0"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host $UserCatch
|
||||
@@ -0,0 +1,14 @@
|
||||
$Server = "PC284.pal.local"
|
||||
$Sessions = (quser /server:$Server) -replace '\s{2,}', ',' | ConvertFrom-Csv
|
||||
|
||||
$Utente = $Sessions.NOMEUTENTE
|
||||
$Sessione = $Sessions.NOMESESSIONE
|
||||
$Stato = $Sessions.STATO
|
||||
$Tempo = $Sessions."INATTIVITÀ ACCESSO"
|
||||
|
||||
Write-Host "Host: "$Server
|
||||
Write-Host "Utente: "$Utente
|
||||
Write-Host "Sessione: "$Sessione
|
||||
Write-Host "Stato: "$Stato
|
||||
Write-Host "Tempo: "$Tempo
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
$app = "PS - UserCatch"
|
||||
$ver = "v 1.0"
|
||||
|
||||
$start = "Stai eseguendo:"
|
||||
$exec = "Lo script $app e' in esecuzione."
|
||||
|
||||
Write-Host $start, $app, $ver
|
||||
Write-Host $exec -fore Yellow
|
||||
|
||||
(1..254) | % {$IP ="172.16.94.$_"; Write-Output "$(
|
||||
ForEach-Object {Test-Connection -ComputerName $IP -Count 1 -ErrorAction:SilentlyContinue -AsJob} | Get-Job | Receive-Job -Wait -AutoRemoveJob | Where-Object {$_.StatusCode -eq 0} | Select-Object -exp Address
|
||||
)"}
|
||||
@@ -0,0 +1,14 @@
|
||||
PS C:\Users\cbo\Documents\Code\PowerShell\Script> .\UserCatch.ps1
|
||||
Stai eseguendo: PS - User Catch v 0.3
|
||||
Lo script PS - User Catch e' in esecuzione.
|
||||
|
||||
172.16.82.191 True
|
||||
172.16.82.192 True Galaxy-A20e.pal.local
|
||||
172.16.82.193 True NB082.pal.local
|
||||
172.16.82.196 True Galaxy-Tab-S4.pal.local
|
||||
172.16.82.197 True PC213.pal.local
|
||||
NOMEUTENTE STATO ACCESSO dc Attivo 20/05/2021
|
||||
|
||||
172.16.82.198 True PC210.pal.local
|
||||
NOMEUTENTE STATO ACCESSO cbo Attivo 25/05/2021
|
||||
|
||||
Reference in New Issue
Block a user