Posts

Showing posts from October, 2017

PowerShell Notes

Install programs through enter pssession ISE is dope Set-netipaddress Set-netipv6protocol How to tell if script exited succsfully -last exit code -so do an if to see if it exited with $last exit code $username Java script -taskkill.exe iexplore.exe -taskkill.exe chrome.exe Using regular expressions to search for critical errors through log files -get-eventlog Using the pipeline to ping multiple computers, using pipeline to connect to multiple computers pipeline -transmits data from one cmmdlet to another -data must be passed into the pipeline to be continued -converttocsv transmits data through the pipeline -exporttocsv does not -clixml has better hierarchy than a .csv file Rejoin computer to domain Test-computersecurechannel –repair Get-member Objects have properties Collection=table Object=row Property=column Objects usually have methods as well, use get-member (or gm) to get details on them PowerShell.exe -Command "Start-Process PowerShell.exe -ArgumentList '-ExecutionPo

Connect to SCCM Site with PowerShell

This script snippet can be used at the beginning of a script to dynamically find SCCM sites and then change directory to an SCCM CAS site, after which scripts can be run using SCCM cmdlets. $PathToInstall = #YourPathHere if (!(test-path ("C:\Program Files (x86)\ConfigMgrConsole\bin\ConfigurationManager.psd1"))) { $Install = Read-host "No Configuration Manager commandlet installed. Would you like to install?[Y/N]"     if ($Install -eq "Y")     {         #Install tools if desired         start-process msiexec.exe -argumentlist "/i $PathToInstall /q" -Wait     }     else     {         #Exits script, as this won't work without SCCM module         Write-host "No Commandlets found, exiting script"         pause         exit     } } #Import modules for AD and SCCM from the start import-module ActiveDirectory import-module ConfigurationManager # (optional) Dynamically retrieve the domain root distinguished name $Dom