Wednesday, April 29, 2020

PowerShell for AD



Get computer by service tag
get-adcomputer -Filter 'serialNumber -eq "123456"' -Properties *


Get computer owner
get-adcomputer -properties * | select ManagedBy


Get group info to file
get-adgroup -properties * | Out-File c:\temp\grp.txt


Get group membership for a user
Get-ADPrincipalGroupMembership | select name | Sort-Object name


Get machines owned by a user
Get-adcomputer -Filter "ManagedBy -eq ''


Validate Credentials
Add-Type -AssemblyName System.DirectoryServices.AccountManagement
$DS = New-Object System.DirectoryServices.AccountManagement.PrincipalContext('domain')
$DS.ValidateCredentials('', '')


Get DirectReports - Sorted by last name, filtering out underscores, and showing desk location.
get-aduser -Properties directreports | Select-Object -ExpandProperty directreports | Get-AdUser -Properties * |Select-Object LegalGivenName, LegalSurName, physicalDeliveryOfficeName | Where-Object {$_.physicalDeliveryOfficeName -ne $null} | Sort-Object LegalSurName

Tuesday, June 26, 2018

Git Commands

git init - Sets up new repo in current directory
git remote add origin https://github.com/user/repo.git - Add a remote repo like bitbucket
git status
git config --global color.ui true  - Add color to output for better readability
git config --global user.name - Change username
git config --global user.email - Change email address
git config --global merge.tool opendiff - set diff custom diff tool
git config --global alias.co checkout - creates a shortcut for checkout called co, git co
git log
git log --pretty=oneline
git log --pretty=oneline -p  - for patch output to see what lines were removed and added
git log --pretty=format:"%h %ad- %s [%an]"
git log --global alias.mylog or alias.lol then just use git mylog or git lol
git log --online --graph  -Shows branches and commits on them
git log --until=1.minute.ago
git log --since=1.day.ago
git log --since=1.month.ago --until=2.weeks.ago
git log --since=2000-1-1 --until=2012-12-21

git add
git commit
git commit -a -m 'Comment' - Commits and stages all at once.
git commit --amend -m 'Comment' - Will amend previous commit with whatever is on staging.

git push - Puts files on remote server.  The name of our remote is origin and the default local branch name is master. The -u tells Git to remember the parameters, so that next time we can simply run git push and Git will know what to do.
git push origin - Pushes local branch to remote repo
git push origin : - Adding the ':' will delete the remote branch
git pull origin master - Get changes from remote location (origin)

git diff HEAD - Show diff of changes by others.
git diff HEAD^ - Parent of latest commit
git diff HEAD^^ - grandparent of latest commit
git diff HEAD~5 - five commits ago
git diff HEAD^..HEAD - second most recent commit vs most recent
git diff sha..sha - compare by sha1 hash of two different commits
git diff branch1 branch2 - compare branches
git diff --since=1.wee.ago --until=1.minute.ago
git diff --staged
git reset - removes file from staging
git reset --soft HEAD^ - undoes the last commit
git reset --hard HEAD^ - undoes the last commit and deletes the files from staging

git checkout -- - Files can be changed back to how they were at the last commit
git branch - Creates a new branch
git branch - Shows all the branches
git branch -r - Shows all remote branches on the repo
git checkout - Switches between branches
git checkout -b - Creates a new branch and switches to it at the same time
git branch -d - Deletes the branch.  Us -D to delete even if unmerged commits exist

git rm - removes files
git rm --cached - stops tracking changes on a file

git merge - Merge changes from one branch to another.  Do this command from the destination branch.
git help
git clone
git remote -v - lists all the origins
git remote show origin - Shows all the remote branches and if they are tracked
git remote prune origin - Cleans up any deleted branches from the repo

git tag - list all tags
git checkout git tag -a v.0.0.3 -m "version 0.0.3" - Add a new tag
git push --tags - Push them to the remote repo

git rebase
git rebase --continue

git blame --date short
Exclude files/folder by adding name to .git/info/exclude
Exclude by pattern as well, *.mp4, logs/*.logs, etc.
Use .gitignore for ignoring log files. 

git rebase -i HEAD~3 - redo last three commits
git stash apply - gets the saved files
git stash list - displays all the stashed code
git stash show stash@{0} - shows details of one particular stash
git stash show --patch - shows the file diffs
git stash apply stash@{1} - gets the stashed code at position 2
git stash drop - to remove from the list
git stash pop - runs both git stash apply and get stash drop
git stash save - saves modified files, restores last commit
git stash save "add optional comment"
git stash save --keep-index - causes the staging area not to be stashed
git stash save --include-untracked - causes untracked files to be stashed too
git stash branch stash@{0} - gets stashed code into new branch
git stash clear - clears away the stash list

-- Deleting History --
git filter-branch --tree-filter 'rm -f ' -- --all - Goes through all branches and removes file from each commit
git filter-branch -f --prune-empty -- --all - Drops empty commits that don't alter any files

-- Line Ending --
git config --global core.autocrlf input - For Unix based systems
git config --global core.autocrlf true - For Windows
-- Cherry Picking --
git cherry-pick
git cherry-pick --edit - Allows you to edit the comment
git cherry-pick --no-commit - Pulls in changes and stages them without committing them
git cherry-pick -x - Adding '-x' adds a commit saying where it was picked from.  Only useful if cherry picked from public branch
git cherry-pick --signoff -- SubModules --
git submodule add
cat .gitmodules - Shows contents of the file
git submodule init
git submodule update
git merge - To add commits without a branch
** Push twice when editing submodules.
git push --recurse-submodules=check
git push --recurse-submodules=on-demand - Force submodules to be pushed with the master branch is pushed.
git config alias.pushall "push --recurse-submodules=on-demand" -Creates shortcut to alwasy push submodules.

-- Reflog --
Restore deleted commit.
git reflog - Shows local copy of log for all actions
git reset --hard
git log --walk-reflogs - Gives greater detail for commits
git branch

Tuesday, May 29, 2018

Angular

Start Angular App: ng serve -o or npm start
Format Bindings: Use pipes.


The Angular team recommends moving filtering and sorting logic in to the component itself.

Angular Module Structure

  • Root application module (AppModule)
  • Feature modules (i.e. ProductModule)
  • Shared module (SharedModule) - Contains common features used across modules.
  • Core module (CoreModule) only imported once and contains your services.
  • (optional) Routing modules

Monday, July 15, 2013

Infragistics TFS Build LicenseException

Occasionally I receive a System.ComponentModel.LicenseException error when doing a build in TFS that contains Infragistics controls. What I have found that fixes the issue is if I open the licenses.licx file and remove all its contents. Once I check it in and attempt the build again, everything works. (TFS 2010, VS 2012)

Tuesday, October 11, 2011

User Group Presentations

Watch User Group presentations for free online.
http://www.usergroup.tv

Tuesday, September 27, 2011

Concatenate Text Files

DOS command for concatenating multiple text files:

-- Syntax
for <variablename> in (<directorylisting>) do <command> <variablename>

-- Exmaple
for %f in (*.log) do type “%f” >> aggregate.txt

Wednesday, March 23, 2011

Timer Job Currupt Memory Error

Issue:
  • Timer jobs failing to complete
  • Receiving errors running psconfig
Purpose:
Caches configuration information (stored in the config database) on each server in the farm. If corruption occurs the issues described above are likely the result.
  1. Start->Administrative Tools->Services
  2. Windows SharePoint Timer v3.0 -> Stop
  3. Drive:\ProgramData\Microsoft\SharePoint\Config\GUID
    1. Delete all the XML files from the directory
    2. Do NOT Delete the .INI File
  4. Open the cache.ini using Notepad and set the number to 1.
    1. Save this file and close Notepad
    2. Do NOT open and edit the cache.ini with WordPad
  5. Recycle the Windows SharePoint Administration Service
  6. Restart the Windows SharePoint Timer Service
  7. You should see XML Files reappear in the cache directory
  8. Note: Perform this on the server experiencing the issue. Most likely it doesn’t have to be performed on all servers.