initial commit

master
Felix Pankratz 2 weeks ago
commit 27a8255ba4

@ -0,0 +1,11 @@
# Collection of command line cheats
## Shell integration
```
function cheat() {
bat -l md -p ~/cheat/cheats/"$1" --color always --theme="Dracula" | tr -d '`'
}
# autocompletion for zsh
compdef '_files -W "/home/panki/cheat"' cheat
```

@ -0,0 +1,18 @@
# global catalog port
`-server dc01.contoso.com:3268`
# set extension attr
`Set-ADUser -replace @{extensionAttribute15='f'}`
# pw never expires
`Get-AdUser -filter { passwordNeverExpires -eq $true -and enabled -eq $true } | Select Name, DistinguishedName`
# get user by SID
`get-aduser -Identity "S-1-5-21-" -server dc01.contoso.com:3268`
# force pw reset
`get-aduser -filter * -SearchBase 'OU=Users,DC=Contoso,DC=com' | set-aduser -ChangePasswordAtLogon $true`
# submit CSR to CA
`certreq -submit -attrib "CertificateTemplate:Webserver Version3" docs_req.req`

@ -0,0 +1,14 @@
# Restore deleted resource
## Find mailbox ID
`Get-MailboxDatabase | foreach {Get-MailboxStatistics -Database $_.DistinguishedName} | where {($_.DisplayName -eq "Room 01.03") -and ($_.DisconnectReason -eq "SoftDeleted" -or "Disabled")} | Format-List DisplayName,DisconnectReason,DisconnectDate,MailboxGuid`
## Create new resource, then restore:
`New-MailboxRestoreRequest -SourceStoreMailbox 369c6ce9-301d-41af-b4cf-cca87d679756 -SourceDatabase MailDB07 -TargetMailbox MULRaumG6.03.410 -AllowLegacyDNMismatch`
# give group permission on mailbox "finance1"
`add-mailboxpermission -Identity finance1 -user CONTOSO\Accounting -AccessRights 'FullAccess'`
# set external mail address
`Enable-MailUser -Identity FreemanG -ExternalEmailAddress gordon.freeman@contoso.com`
# add access to calendar
`Add-MailboxFolderPermission -Identity Maintenance@contoso.com:\Calendar -User gordon.freeman@contoso.com -AccessRights Editor`

@ -0,0 +1,14 @@
# show cert info
`openssl x509 -noout -text -in cert.pem`
# import pkcs12 into jks
`keytool -importkeystore -srckeystore mypfxfile.pfx -srcstoretype pkcs12 -destkeystore clientcert.jks -deststoretype JKS`
# pkcs12/pfx to pem/crt + key
## export key
`openssl pkcs12 -in filename.pfx -nocerts -out key.pem`
## remove passphrase
`openssl rsa -in key.pem -out server.key`
## export cert
`openssl pkcs12 -in filename.pfx -clcerts -nokeys -out cert.pem`

@ -0,0 +1,8 @@
# Replace column names
`| Select-Object @{N='samAccountName'; E={$_.InputObject}},@{N='Action'; E={$_.SideIndicator}}`
# convert timestamp
`Select @{N='LastLogon'; E={[DateTime]::FromFileTime($_.LastLogon)}}`
# check error
`$Error[0] | fl *`

@ -0,0 +1,2 @@
# Compare folder contents recursively (no move)
`robocopy source dest /l /e /fp /np /njh /ndl`

@ -0,0 +1,5 @@
# list all tables
`.tables`
# select all
`select * from ConfigUser`

@ -0,0 +1,6 @@
# portforward windows localhost to wsl
`netsh interface portproxy add v4tov4 listenport=1080 listenaddress=127.0.0.1 connectport=1080 connectaddress=$(hostname -I)`
# update computer account group membership (without reboot)
`klist -lh 0 -li 0x3e7 purge`
`gpupdate`

@ -0,0 +1,2 @@
# mount admin share
`sudo --preserve-env=HOME mount -t cifs -o username=freemang,domain=CONTOSO //citadel.contoso.com/c$ /mnt/srv`
Loading…
Cancel
Save