Posted in Bash Powershell

Instaliraj Powershell na Ubuntu 22.04

sudo apt-get update sudo apt-get install -y wget apt-transport-https software-properties-common wget -q "https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb" sudo dpkg -i packages-microsoft-prod.deb sudo apt-get update sudo apt-get install -y powershell…

Posted in Powershell Python

Epoch date time u ljudski oblik

powershell.ps1 $UnixTime = 1711000300 $epoch = [DateTime]::new(1970, 1, 1, 0, 0, 0, [DateTimeKind]::UTC) $date = $epoch.AddSeconds($UnixTime).ToLocalTime() python.py (hex epoch) import datetime VrijemeHex = "61a73207" VrijemeDec…

Posted in Powershell SysAdmin

Powershell – All history

Get-Content ((Get-PSReadlineOption).HistorySavePath) posh pwsh powershell history all xposh xpwsh xpowershell xhistory xall

Posted in CLI Powershell

Powershell – Prikaži dugačku poruku

[System.Reflection.Assembly]::LoadWithPartialName(‘System.Windows.Forms’) [System.Windows.Forms.MessageBox]::Show("’….-….1….-….2….-….3….-….4….-….5….-….6….-….7….-….8….-….9….-…100…-….1….-….2….-….3….-….4….-….5….-….6….-….7….-….8….-….9….-…200…-….1….-….2….-….3….-….4….-….5….-….6….-….7….-….8….-….9….-..300","NASLOV")

Posted in Bash CLI CMD Powershell

OCR .PDF datoteke

ocrmypdf -O 3 –tesseract-oem=3 –language=hrv –force-ocr –output-type pdf –sidecar OCR.txt inputFile.pdf temp.pdf Po završetku će datoteka “OCR.txt” imati tekst iz datoteke “inputFile.pdf”. Datoteka “temp.pdf” je…

Posted in Bash CLI Powershell

PDF kontrast i to

magick convert -monitor -density 150 $inputFile -auto-level -gamma .4 -compress JPEG -quality 80 -adaptive-sharpen 2 -antialias -compress JPEG $outputFile https://imagemagick.org/ pdf xpdf jpg xjpg jpeg…

Posted in CLI Powershell

Powershell full history

type (Get-PSReadlineOption).HistorySavePath pwsh xpwsh xpowershell xhistory xfull sve xsve xall all xtotal total

Posted in CLI Powershell Windows

Windows firewall i Powershell

New-NetFirewallRule -DisplayName "BlokirajOut443" -Direction outbound -Profile Any -Action Block -RemotePort 443,567-678 -Protocol TCP -Program C:\Windows\Notepad.exe Remove-NetFirewallRule -DisplayName "BlokirajOut443" pwsh ps xpwsh xps firewall xfirewall fw…

Posted in CMD Powershell

Skriven prozor

batch.cmd cmd /c start /min "" pwsh -WindowStyle Hidden -ExecutionPolicy Bypass -command "$nestonesto=neštonešto" powershell.ps1 pwsh -WindowStyle Hidden -ExecutionPolicy Bypass -command "$nestonesto=neštonešto"  

Posted in Powershell

Štoperica / stopwatch

powershell.ps1 Štoperica 4 sekunde: $stoperica = new-object system.diagnostics.stopwatch ; $stoperica.start() ; while ($stoperica.elapsed.Seconds –lt 4) {$null}; write-host "Kraj" ; $stoperica.stop()  

Posted in Bash CLI CMD Powershell SysAdmin

Nextcloud – Batch upload

Import iz commandlineta u NextCloud:  curl -u <%USERNAME%>:<%LOZINKA%>   -T X:\Proba123.pdf   http://sljedecioblak.server.tld/remote.php/dav/files/datotetke/ xcurl xnextcloud upload batch cli commandline command line xcli xcommandline script xscript

Posted in Powershell

Koja je boja teksta i podloge u konzoli?

powershell.ps1 [System.Console]::ForegroundColor [System.Console]::BackgroundColor xps1 xforegroundcolorx xBackgroundColorx xcolorx xcursorx xboja xtekst xpodloga xpozadina boja teksta boja podloge boja pozadine

Posted in CMD Powershell

Popis svih ekstenzija u poddirektorjima

powershell.ps1 $ekstenzije = @{}; Get-ChildItem *.* -Recurse | ForEach-Object { $ekstenzije[$_.Extension]++ }; Write-Output $ekstenzije Rezultat: .gif 14 .tif 15 .pdf 1200 .jpg 1267 .png 90…

Posted in Powershell SysAdmin

Prebroj datoteke

powershell.ps1 (Get-ChildItem "neštonešto*.txt" -File | Measure-Object | %{$_.Count}) prebrojavanje datoteka xprebrojavanje xdatoteka count files xcount xfiles number of files broj datoteka

Posted in CLI Powershell

Izmišljatelju lozinaka, izmisli mi lozinku

Generiraj alfanumaričku lozinku od 24 znaka bash.sh …(jednoga dana)… powershell.ps1 -join ((65..90) + (97..122) + (48..57)| Get-Random -Count 24 | ForEach-Object {[char]$_}) python.py …(jednoga dana,…

Posted in Bash CLI CMD Linux Powershell Sigurnost SysAdmin Windows

Kako izračunati CRC SHA

powershell.ps1 Get-FileHash -Path datoteka.zip     # default=SHA256 Get-FileHash -Path datoteka.zip -Algorithm SHA1 batch.cmd certutil.exe -hashfile datoteka.zip SHA256 certutil.exe -hashfile datoteka.zip SHA1 bash.sh sha256sum datoteka.zip sha1sum…

Posted in Powershell

Powershell Write-Host – Preusmjeravanje ispisa u datoteku

Iz Powershella ne možeš uobičajenim opcijama preusmjeriti ispis u datoteku jerbo Write-Host, logičko zar ne, piše na – host! ALI… zato ovo radi: pwsh -file…

Posted in Bash CLI JavaScript Powershell Python

Postoji li datoteka ili ne, pitanje je tad

bash.sh if [   -f "datoteka.txt" ]; then echo "Postoji"   ; fi if [ ! -f "datoteka.xyz" ]; then echo "Ne postoji"; fi batch.cmd if   …

Posted in Bash CMD Powershell Python

if .. then .. else i
Ima li CLI argumenta i koliko?

bash.sh if [ $# -eq 0 ] then echo "Nema argumenata. Le kraj." exit 99 fi if [ -z $1 ]   # provjeri je li…

Posted in Bash CMD Powershell Python

Parametri naredbenog retka iliti
command line parameters

bash.sh #!/bin/bash argumentum1=$1 agrumenat2=$2 echo $argumentum1 $argumenat2 echo Naziv/path skripte jest 0: $0 batch.cmd @echo off set argumentum1=%1 set argumenat2=%2 echo %argumentum1% %argumenat2% echo Naziv/path…