Difference between revisions of "General Powershell Notes"

From Michael's Information Zone
Jump to navigation Jump to search
Line 1: Line 1:
 
<ref>https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/enable-psremoting</ref>
 
<ref>https://msdn.microsoft.com/en-us/powershell/reference/5.1/microsoft.powershell.core/enable-psremoting</ref>
 +
 +
==Access to Exchange Online==
 +
Log into exchange online.
 +
<pre>
 +
$livecred = get-credential
 +
$session = New-PSSession -configurationname microsoft.exchange -connectionuri https://ps.outlook.com/powershell/ -credential $livecred -authentication basic -allowredirection
 +
import-pssession $session
 +
</pre>
 +
 
==Powershell Version==
 
==Powershell Version==
 
<ref>https://stackoverflow.com/questions/1825585/determine-installed-powershell-version</ref>
 
<ref>https://stackoverflow.com/questions/1825585/determine-installed-powershell-version</ref>

Revision as of 09:59, 27 February 2019

[1]

Access to Exchange Online

Log into exchange online.

$livecred = get-credential
$session = New-PSSession -configurationname microsoft.exchange -connectionuri https://ps.outlook.com/powershell/ -credential $livecred -authentication basic -allowredirection
import-pssession $session

Powershell Version

[2]

$PSVersionTable

Import Excel Spreadsheets

[3]This will save the hassle of converting to CSV all the time.

Install-Module ImportExcel

Import-Excel '.\test.xlsx' -StartRow 3 -EndRow 5 -StartColumne 2 -EndColumne 4

NTFS Permissions

[4] [5]

Get-Command –Module NTFSSecurity
Get-NTFSAccess -path .\Contacts
add-ntfsaccess -path .\contacts -account first.last -accessrights read

Passing Passwords to PSSession

[6] Convert to secure string then call from file. This following pulls from stdin as a secure string (converts what you type), then converts that to something (I'm still new to Microsoft's ways of doing things), then stores as a file.

read-host -assecurestring | convertfrom-securestring | out-file C:\securestring.txt