<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Powershell on The Network Stack</title>
    <link>https://thenetworkstack.com/tags/powershell/</link>
    <description>Recent content in Powershell on The Network Stack</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 04 Aug 2017 19:28:01 +0000</lastBuildDate>
    <atom:link href="https://thenetworkstack.com/tags/powershell/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Active Directory Powershell</title>
      <link>https://thenetworkstack.com/active-directory-powershell/</link>
      <pubDate>Fri, 04 Aug 2017 19:28:01 +0000</pubDate>
      <guid>https://thenetworkstack.com/active-directory-powershell/</guid>
      <description>&lt;p&gt;Using this page to keep track of all the useful powershell &amp;ldquo;mini-scripts&amp;rdquo; I&amp;rsquo;ve used:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Copy users from one security group to another security group&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Add-ADGroupMember -Identity destination-group-name -Members (Get-ADGroupMember -Identity source-group-name -Recursive)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Add &lt;em&gt;enabled&lt;/em&gt; users from an OU to a security group&lt;/strong&gt;&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Get-ADUser -SearchBase &amp;#39;OU=Your-OU,DC=corp,DC=company,DC=com&amp;#39; -Filter {Enabled -eq $true} | ForEach-Object {Add-ADGroupMember -Identity &amp;#39;your-group-name&amp;#39; -Members $_ }
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Add users from a CSV file to a security group (username column is called &amp;ldquo;name&amp;rdquo;)&lt;/strong&gt;&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Using this page to keep track of all the useful powershell &ldquo;mini-scripts&rdquo; I&rsquo;ve used:</p>
<p><strong>Copy users from one security group to another security group</strong></p>
<pre tabindex="0"><code>Add-ADGroupMember -Identity destination-group-name -Members (Get-ADGroupMember -Identity source-group-name -Recursive)
</code></pre><p><strong>Add <em>enabled</em> users from an OU to a security group</strong></p>
<pre tabindex="0"><code>Get-ADUser -SearchBase &#39;OU=Your-OU,DC=corp,DC=company,DC=com&#39; -Filter {Enabled -eq $true} | ForEach-Object {Add-ADGroupMember -Identity &#39;your-group-name&#39; -Members $_ }
</code></pre><p><strong>Add users from a CSV file to a security group (username column is called &ldquo;name&rdquo;)</strong></p>
<pre tabindex="0"><code>import-csv c:\users.csv | Foreach-Object {add-adgroupmember -Identity your-group-name -Members $_.name}
</code></pre><p><strong>Update user objects with organization attributes from a CSV file</strong></p>
<pre tabindex="0"><code>import-csv c:\users.csv | Foreach-Object {Set-ADUser -Identity $_.name -Department $_.department -Title $_.title -Manager $_.manager}
</code></pre><p><strong>Create security-groups from a CSV file (group-name column is called &ldquo;name&rdquo;)</strong></p>
<pre tabindex="0"><code>import-csv c:\groups.csv | Foreach-Object {new-adgroup -name $_.name -GroupCategory security -GroupScope global -Path &#34;ou=Your-OU,dc=corp,dc=company,dc=com&#34;}
</code></pre><p><strong>Export list of all <em>enabled</em> users in an OU</strong></p>
<pre tabindex="0"><code>Get-ADUser -SearchBase &#39;OU=Your-OU,DC=corp,DC=company,DC=com&#39; -Filter {Enabled -eq $true} -Property * | Select -Property Name,SamAccountName,UserPrincipalName,mail,Title,Manager,Department | export-csv &#39;c:\users.csv&#39; -notype
</code></pre><p><strong>Export list of all <em>enabled</em> users in an security group</strong></p>
<pre tabindex="0"><code>Get-ADGroupMember -Identity your-group-name | ? ObjectClass -eq &#34;User&#34; | Get-ADUser | ? Enabled | Select Name | out-file C:\group_membership.txt
</code></pre>]]></content:encoded>
    </item>
    <item>
      <title>Office 365 - Powershell</title>
      <link>https://thenetworkstack.com/office-365-powershell/</link>
      <pubDate>Tue, 12 Apr 2016 06:02:15 +0000</pubDate>
      <guid>https://thenetworkstack.com/office-365-powershell/</guid>
      <description>&lt;p&gt;Connecting to Office 365 via Powershell for the first time? Here are the steps to get started:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Install the &lt;a href=&#34;http://go.microsoft.com/fwlink/?LinkID=286152&#34;&gt;Microsoft Online Services Sign-In Assistant for IT Professionals RTW&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Install the &lt;a href=&#34;http://go.microsoft.com/fwlink/p/?linkid=236297&#34;&gt;Azure Active Directory Module for Windows Powershell (64-bit version)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Open Powershell and run this command the first time you connect on your computer:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Set-ExecutionPolicy RemoteSigned
&lt;/code&gt;&lt;/pre&gt;&lt;ol&gt;
&lt;li&gt;Next, run these three commands (you&amp;rsquo;ll do this everytime you want to connect):&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $Session
&lt;/code&gt;&lt;/pre&gt;&lt;ol&gt;
&lt;li&gt;You should now be connected.  When finished, run:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Remove-PSSession $Session
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Here is an awesome project on github that is a Office 365 Powershell GUI: &lt;a href=&#34;https://github.com/bwya77/O365-Administration-Center&#34;&gt;https://github.com/bwya77/O365-Administration-Center&lt;/a&gt;&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Connecting to Office 365 via Powershell for the first time? Here are the steps to get started:</p>
<ol>
<li>Install the <a href="http://go.microsoft.com/fwlink/?LinkID=286152">Microsoft Online Services Sign-In Assistant for IT Professionals RTW</a></li>
<li>Install the <a href="http://go.microsoft.com/fwlink/p/?linkid=236297">Azure Active Directory Module for Windows Powershell (64-bit version)</a></li>
<li>Open Powershell and run this command the first time you connect on your computer:</li>
</ol>
<pre tabindex="0"><code>Set-ExecutionPolicy RemoteSigned
</code></pre><ol>
<li>Next, run these three commands (you&rsquo;ll do this everytime you want to connect):</li>
</ol>
<pre tabindex="0"><code>$UserCredential = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

Import-PSSession $Session
</code></pre><ol>
<li>You should now be connected.  When finished, run:</li>
</ol>
<pre tabindex="0"><code>Remove-PSSession $Session
</code></pre><p><strong>Update:</strong> Here is an awesome project on github that is a Office 365 Powershell GUI: <a href="https://github.com/bwya77/O365-Administration-Center">https://github.com/bwya77/O365-Administration-Center</a></p>
<p>Microsoft References:</p>
<p><a href="https://technet.microsoft.com/en-ca/library/jj151815.aspx#bkmk_installmodule">https://technet.microsoft.com/en-ca/library/jj151815.aspx#bkmk_installmodule</a><br>
<a href="https://technet.microsoft.com/en-us/library/jj984289(v=exchg.160).aspx">https://technet.microsoft.com/en-us/library/jj984289(v=exchg.160).aspx</a></p>
]]></content:encoded>
    </item>
    <item>
      <title>Office 365 Full Access Mailbox Permissions</title>
      <link>https://thenetworkstack.com/office-365-full-access-mailbox-permissions/</link>
      <pubDate>Mon, 01 Apr 2013 05:44:05 +0000</pubDate>
      <guid>https://thenetworkstack.com/office-365-full-access-mailbox-permissions/</guid>
      <description>&lt;p&gt;If you administer an Office365/Exchange Online organization, you might have noticed you cannot modify Full Access/Send As permissions from the web console. You need to change these permissions through PowerShell; here are the required steps:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The first time you do this, make sure the following steps have been completed:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Right click and run PowerShell as Administrator (Start -&amp;gt; Programs -&amp;gt; Accessories -&amp;gt; Windows PowerShell -&amp;gt; Windows PowerShell) on your local PC&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>If you administer an Office365/Exchange Online organization, you might have noticed you cannot modify Full Access/Send As permissions from the web console. You need to change these permissions through PowerShell; here are the required steps:</p>
<p><strong>The first time you do this, make sure the following steps have been completed:</strong></p>
<p>Right click and run PowerShell as Administrator (Start -&gt; Programs -&gt; Accessories -&gt; Windows PowerShell -&gt; Windows PowerShell) on your local PC</p>
<p>Verify you are running PowerShell 2.0 - Enter $PSVersionTable in the prompt and hit enter</p>
<p>Allow execution of scripts by entering the following command: Set-ExecutionPolicy Unrestricted</p>
<p><strong>Once those two steps have been completed, you can start from here:</strong></p>
<ol>
<li>Enter the following command and input your Exchange admin credentials when prompted:</li>
</ol>
<p><code>$LiveCred = Get-Credential</code></p>
<ol>
<li>Once completed, enter this command next:</li>
</ol>
<p><code>$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection</code></p>
<ol>
<li>Next, enter the following command to import server-side commands:</li>
</ol>
<p><code>Import-PSSession $Session</code></p>
<ol>
<li>To allow user BossOne to have full access to user WorkerOne, enter the following command:</li>
</ol>
<p><code>Add-MailboxPermission -Identity &quot;WorkerOne&quot; -User BossOne -AccessRights FullAccess</code></p>
<ol>
<li>Verify your work with:</li>
</ol>
<p><code>Get-MailboxPermission Username</code></p>
<ol>
<li>Once completed, discconect from the remote session with:</li>
</ol>
<p><code>Remove-PSSession $Session</code></p>
<p><strong>If you also need to add &ldquo;SendAs&rdquo; permissions, the command is:</strong></p>
<p><code>Add-RecipientPermission &quot;mailboxuser&quot; -AccessRights SendAs -Trustee &quot;user&quot;</code></p>
<p>Verification command is:</p>
<p><code>Get-RecipientPermission Username</code></p>
<p><a href="http://help.outlook.com/en-us/140/cc952755.aspx">http://help.outlook.com/en-us/140/cc952755.aspx</a></p>
]]></content:encoded>
    </item>
  </channel>
</rss>
