PowerShell – Import-Pssession is not Importing Cmdlets for O365 Exchange Online

August 30, 2017

 

I noticed that after connecting to O365 Exchange Online using PowerShell, the connection was done OK.

But I could recognize any of the Cmdlets after connecting Sad smile

 

SOLUTION :

$LiveCred = Get-Credential -credential "patrick.taels@plastiflex.com"
   $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection
Import-Module (Import-PSSession $Session -WarningAction SilentlyContinue -AllowClobber) -Global 

 

As you can notice you need to add the Import-Module( … –AllowClobber) –Global Command and Parameters …

Enjoy !

Advertisements

test

August 24, 2017

Test OLW Syntax Highlighter

CLS
# http://www.c-sharpcorner.com/UploadFile/40e97e/calculating-size-of-site-collection-sub-sites-in-multiple-w/

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}


$URL = "http://wss.plastiflexgroup.com/"

$Site = New-Object Microsoft.SharePoint.SPSite($URL)


$spWebApp = $site.WebApplication

# Start Looping throurgh all site Collections and Sub Sites
    foreach ( $spWeb in $spWebApp.Sites )
    {
      write-host "Site Collection: " $spWeb.URL
      write-host "-------------------------------------------------------------------"

$rootUrl = $spWeb.URL # "http://YourSharePointSite.com/"; 

$rootSite = new-object Microsoft.SharePoint.SPSite($rootUrl); 

$array = @()

$siteCollectionSize = 0;

foreach($web in $rootSite.AllWebs) 
{

    if ($web.Url.StartsWith($rootUrl))
    {

        $websize = GetFolderSize $web.RootFolder;

        foreach($recycleBinItem in $web.RecycleBin)
        {
           $websize += $recycleBinItem.Size;
        }

        $formatSize = FormatBytes $websize;

        $url = $web.Url;

         # Create object and store in array
        $obj = New-Object System.Object
        $obj | Add-Member -type NoteProperty -name "Description" -value "$url"
        $obj | Add-Member -type NoteProperty -name "Size" -value "$formatSize"

        $array += $obj

        [system.double]$siteCollectionSize += $websize
    }
}

$formatSize = FormatBytes $siteCollectionSize;

# Create object and store in array
$obj = New-Object System.Object
$obj | Add-Member -type NoteProperty -name "Description" -value "[Total Size]"
$obj | Add-Member -type NoteProperty -name "Size" -value "[$formatSize]"

$array += $obj

# Display
foreach($item in $array)
{
    write-output $item
}


# Write to HTML
# $array | Select-Object | ConvertTo-Html -title "Site Size" | Set-Content .\SiteSize.html
 

# Function calculating folder size
Function GetFolderSize($folder)
{
    [system.double]$filesize = 0;

    foreach ($file in $folder.Files)
    {
        $filesize += $file.TotalLength;

        foreach ($fileVersion in $file.Versions)
        {
            $filesize += $fileVersion.Size;
        }
    }

    foreach ($subfolder in $folder.SubFolders)
    {
        $filesize += GetFolderSize $subfolder
    }

    return $filesize;
}
 

# Function to format in MB
function FormatBytes ($bytes)
{
    switch ($bytes)
    {
        {$bytes -ge 1TB} {"{0:n$sigDigits}" -f ($bytes/1TB) + " TB" ; break}
        {$bytes -ge 1GB} {"{0:n$sigDigits}" -f ($bytes/1GB) + " GB" ; break}
        {$bytes -ge 1MB} {"{0:n$sigDigits}" -f ($bytes/1MB) + " MB" ; break}
        {$bytes -ge 1KB} {"{0:n$sigDigits}" -f ($bytes/1KB) + " KB" ; break}
        Default { "{0:n$sigDigits}" -f $bytes + " Bytes" }
    }
 }
    Write-host ""
}

Enjoy !


SharePoint – How to see the Storage Size for All Site Collections

August 23, 2017

This can be done in various ways …

In Site Settings you can go to Storage Metrics

image

Example :

image

But this is a labor intensive way to do for all site collections … Sad smile

SOLUTION :

1. Using PowerShell

This is a script I modified from the original to loop through all site collections to fit my needs …

CLS
# http://www.c-sharpcorner.com/UploadFile/40e97e/calculating-size-of-site-collection-sub-sites-in-multiple-w/

if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null)
{
    Add-PSSnapin Microsoft.SharePoint.PowerShell;
}


$URL = "http://wss.plastiflexgroup.com/"

$Site = New-Object Microsoft.SharePoint.SPSite($URL)


$spWebApp = $site.WebApplication

# Start Looping throurgh all site Collections and Sub Sites
    foreach ( $spWeb in $spWebApp.Sites )
    {
      write-host "Site Collection: " $spWeb.URL
      write-host "-------------------------------------------------------------------"

$rootUrl = $spWeb.URL # "http://YourSharePointSite.com/"; 

$rootSite = new-object Microsoft.SharePoint.SPSite($rootUrl); 

$array = @()

$siteCollectionSize = 0;

foreach($web in $rootSite.AllWebs) 
{

    if ($web.Url.StartsWith($rootUrl))
    {

        $websize = GetFolderSize $web.RootFolder;

        foreach($recycleBinItem in $web.RecycleBin)
        {
           $websize += $recycleBinItem.Size;
        }

        $formatSize = FormatBytes $websize;

        $url = $web.Url;

         # Create object and store in array
        $obj = New-Object System.Object
        $obj | Add-Member -type NoteProperty -name "Description" -value "$url"
        $obj | Add-Member -type NoteProperty -name "Size" -value "$formatSize"

        $array += $obj

        [system.double]$siteCollectionSize += $websize
    }
}

$formatSize = FormatBytes $siteCollectionSize;

# Create object and store in array
$obj = New-Object System.Object
$obj | Add-Member -type NoteProperty -name "Description" -value "[Total Size]"
$obj | Add-Member -type NoteProperty -name "Size" -value "[$formatSize]"

$array += $obj

# Display
foreach($item in $array)
{
    write-output $item
}


# Write to HTML
# $array | Select-Object | ConvertTo-Html -title "Site Size" | Set-Content .\SiteSize.html
 

# Function calculating folder size
Function GetFolderSize($folder)
{
    [system.double]$filesize = 0;

    foreach ($file in $folder.Files)
    {
        $filesize += $file.TotalLength;

        foreach ($fileVersion in $file.Versions)
        {
            $filesize += $fileVersion.Size;
        }
    }

    foreach ($subfolder in $folder.SubFolders)
    {
        $filesize += GetFolderSize $subfolder
    }

    return $filesize;
}
 

# Function to format in MB
function FormatBytes ($bytes)
{
    switch ($bytes)
    {
        {$bytes -ge 1TB} {"{0:n$sigDigits}" -f ($bytes/1TB) + " TB" ; break}
        {$bytes -ge 1GB} {"{0:n$sigDigits}" -f ($bytes/1GB) + " GB" ; break}
        {$bytes -ge 1MB} {"{0:n$sigDigits}" -f ($bytes/1MB) + " MB" ; break}
        {$bytes -ge 1KB} {"{0:n$sigDigits}" -f ($bytes/1KB) + " KB" ; break}
        Default { "{0:n$sigDigits}" -f $bytes + " Bytes" }
    }
 }
    Write-host ""
}

2. Using Free Tools

You get a nice Output to console or to HTML

clip_image002

But there is a much easier way to get thing going using standard (Free) tools. 🙂

1. Open the Site of Site Collections Library in Explorer

image

2. Once opened map it to a Drive letter.

clip_image006

3. Open de folder with your favorite Space Analysis Tool.

1. Space Monger

In my case nothing beats the very old “Space Monger” App. Because you have a graphical view of which folders and files consume the most storage …

And it give your drill through up and down to zoom in to the file level…

clip_image008

clip_image010

Not sure if this is still around on the net … ?

2. Folder Size

Another simple tool to use is Folder Size : http://foldersize.sourceforge.net/

After installation you can define which type of drives to monitor. See Control Panel Settings

clip_image012

clip_image014

Enjoy !


AutoIT – Meets PowerShell using .NET Common Language Runtime (CLR) Framework

August 9, 2017

Since we AutoIT have got access the to the .NET Common Language Runtime (CLR) Framework 

We can access the PowerShell Automation Classes as well.

This is really powerfull stuff … because we can reuse .NET code as well as all the native CMDlet’s and scripts.

As you can see the script runs an PowerShell command that lists all running processes on your machine. And return the Output to a .NET Grid.

image

Which runs inside our Unmanaged Host, isn’t that cool …Smile

We can access native .NET Classes as well because PS runs on top off it.

Next is that you could access any kind of Cloud Web Service using the multitude of PS Modules that are available.

As well as accessing Custom Build Assemblies.

How to :

For more information on how to access .NET Classes see the above post about .NET Common Language CLR Framework.

Or Join the most friendly and helpful AutoIT Community on the net Smile

I will post some more examples and How To’s later on, so stay tuned …


Windows 2016 – Computer Browser Service Missing ?

August 8, 2017

Compared to older versions of Windows Server some services are missing like :

Computer Browser Service

Network Discovery Service

Making that you don’t see the computers available in your network by default …

image

Solution :

Make sure that the SHARING options for the DOMAIN profile is turned on !

image

Next check that the DNS Client Service is running

image

Next check that the Function Discovery Resource Publication Service is running

image

Next check that the SSD Discovery Service is running

image

Make sure the Firewall is allowing network discovery

netsh advfirewall firewall set rule group="Network Discovery" new enable=Yes

Go and check again to what is appearing now…

image

If it does not work you can try turning on the UPnP Device Host Service. Which I don’t recommend since UPnP can be a weak spot in your network…

Enjoy!


GreenShot – Adding OCR features

August 7, 2017

One of my all time favorites is use GreenShot Screen Capturer. And most welcome is the add the MS OCR plugin.

It was a long time since I installed it, and starting to use a new laptop I was missing this feature the most Sad smile

 

1. So checked the that in MS Office 2010 the OCR feature was enabled.

 

image

2. I checked that his was also installed in SP Designer 2010

image

 

3. I also downloaded the MODI Convertor Components seperately

http://www.microsoft.com/en-us/download/details.aspx?id=30328

clip_image002

clip_image003

 

But still no Success Sad smile

 

image

Because since MS Office 2010 the MODI (MS Office Document Imaging or OCR components) are not included anymore…

 

Solution :

So  need to install MS SharePoint Designer 2007, and activate the MODI components.

 

image

Once installed you can the nice OCR feature again available.

image

As you can see the SP Designer 2010 can be installed side by side with  SP Designer 2007 if needed…

 

image

 

Enjoy !


Windows – Group Policy Error Event ID 1030

August 3, 2017

After a Reboot of a Domain Controller Server 2008r2 I got many Errors Event ID 1030

image

And as well a Warning event LSA Event ID  40961 ?

The Security System could not establish a secured connection with the server ldap/xxx/xxx. No authentication protocol was available.

Diagnostics :

After reading on the net, I did several Diagnostics test:

dcdiag /v /c /d /e /s:%dcname% > c:\dcdiag.txt

image

repadmin /showrepl %dcname% /verbose /all /intersite >c:\repl.txt

image

May errors appear in there but did not ring a bell to me ?

I also did a machine Pwd reset on the domain controller that had the issue, but not success too Sad smile

The nltest.exe /dsregdns was OK but did not solve it to ??Baring teeth smile

image

Solution :

After trying all of the above did not help …

But simply restarting the AD Domain Services

image

It gave a few warnings but after that everything was back to normal.

image

Enjoy !