plesk db "SELECT d.name AS 'Subscription', IF (p.value = 'true', 'Enabled', 'Disabled') AS 'DKIM Status' FROM domains d LEFT JOIN DomainServices ds ON d.id = ds.dom_id LEFT JOIN (SELECT * FROM Parameters WHERE parameter = 'domain_keys_sign') p ON ds.parameters_id = p.id WHERE ds.type = 'mail';"
Tag: Windows
Restore correct ownership on a domain folder and all its contents
INFO=($(MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql -uadmin psa -sN -e'SELECT h.www_root,s.login FROM domains d, hosting h, sys_users s WHERE s.id=h.sys_user_id AND h.dom_id=d.id AND d.name="example.com"')); chown -R ${INFO[1]}:psacln ${INFO[0]}; chown ${INFO[1]}:psaserv ${INFO[0]}
Starting from Plesk 17.8 it can be done easier
plesk repair fs example.com
List passwords for all mailboxes
plesk sbin mail_auth_view
Extract an .msi file
msiexec /a C:\path\to\the.msi TARGETDIR=C:\path\to\extraction\dir\ /qn
Check if the server is hosted on Google Cloud or AWS
- AWS
curl -Lso /dev/null http://169.254.169.254/latest/meta-data && echo "Definitely AWS"
if ((IWR -URI http://169.254.169.254/latest/meta-data -UseBasicParsing) -ne $null) { echo "Definitely AWS" }
- GCN
curl -Lso /dev/null -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/ && echo "Definitely GC"
PowerShell 3.0 or newer is required to send custom headers
if ((IWR -URI "http://metadata.google.internal/computeMetadata/v1/" -Headers @{"Metadata-Flavor"="Google"} -UseBasicParsing) -ne $null) { echo "Definitely GC" }
Show all TCP ports in “Listening” state and their owner processes
netstat -bonap tcp | Select-String "LISTENING" -Context 0,1
Show permissions for a file and all parent folders
function namei { If ( $args[0] -eq $null ) { $path = ($pwd).Path } Else { $path = $args[0] } If ( -not (Test-Path -Path $path) ) { echo "Path does not exist" return } While ( $path -ne "" ) { $acl = Get-ACL -Path $path echo $path "`r`n" ( $acl | Select -Property Owner,Group | FL | Out-String ).Trim() $acl | Select -Expand Access | Select -Property FileSystemRights,AccessControlType,IdentityReference,IsInherited | FT $path = $path | Split-Path } }
namei C:\Windows
Download a file via PowerShell
Invoke-WebRequest -URI https://google.com/favicon.ico -OutFile file.ico
A bit faster alternative with direct invokation of .NET classes
(New-Object System.Net.WebClient).DownloadFile("https://google.com/favicon.ico", "file.ico")
Apply RegExp to IIS bindings
PowerShell WebAdministration module is required to run Get-Website cmdlet
Get-Website | Where-Object { $_.Bindings.Collection -match ".*8443.*" }