PowerShell – Limit OneDrive4Business Synchronization to certain AD Domains

March 29, 2019

In the Onedrive4Business Admin Portal you can define which user that are part of a certain AD Domain are allowed to sync.

image

Solution :

You need to get the AD GUID’s first using the PowerShell Get-ADDomain Cmdlet.

See here on how to.

image

image

Enter the GUID’s and save it.

And choose to Block MAC devices if needed.

Enjoy !

Advertisements

SharePoint – Online managing Files On-Demand

March 26, 2019

The new feature of SharePoint and Onedrive4business SYNC. In combination with Windows 10.

Is that you can now determine whether you want to have all files Offline available or NOT. just to save space on your disk.

Read more here

SOLUTION :

Use Attrib.exe to manage the Online-OnDemand settings on a file level.

image

image

Let’s get rid of the digital waste !

Enjoy!


SharePoint – Online Security and Security by Obscurity

March 22, 2019

SharePoint Online Security settings are scattered all around… Sad smile

Next problem is that the Online version OOTB might not give you all the security features you need ?

So you will have to apply some tricks to fool the users.

Here is an overview of what is to your disposal ….

SP Security :

SharePoint delivers a Security Model that is a combination of AD user & Groups with SP Users & Groups.

See Managing the Security Model for more info.

These users and “Nested” Groups can be used to secure your Site Collections on different levels

image

Using Site Settings –> People and Groups and Site Permissions

image

To set security on different levels

1. Site level
2. List and Library security
3. Record level Security

See here for more info

What is Record level Permissions versus Record level Security, see here for more info.

Setting Record Level Security will also have a performance hit !  So try to avoid it as much as possible.

– Search Security
Via Site Settings you can refine the security on the Search

image

So let’s say you don’t want to have the users see the search EVERYTHING option

image

Go to SITE SETTINGS –> SEARCH Settings

image

Delete the EVERYTHING from the list.

Disable File and Folder Sharing :

image

Go to SITE SETTINGS –> Site Permissions –> Access Request Settings

 

SP Security by Obscurity :


Using Target Audience settings :

This is not a real security because the SP Search will ignore the target audience settings !!


– Hiding List or Document Library records using Audience Targeting :

On the list or Library activate Audience Targeting

image

You have to use it in combination of the Content Query Web Part

See here on how to.

– Hiding Web Parts using Audience Targeting :

This is done using the EDIT Web Part feature

image

In the Advanced Section you specify the TARGET Audience user(s) or group(s).

image image

You can use different other settings to HIDE Web Part features from the users

– Select a different VIEW to limit and filter the records shown in the Web Part. And hide the TOOL Bar if needed.

image

In the MISCELANEOUS section you can hide different sections

image

Here you decide to hide the Web Part Toolbar and only leave the INLINE LIST SEARCH available.

– Hiding Search options using Audience Targeting

image

Next you can  set Targeting Audience using SP Groups to limit the search this site feature for certain users.

– Hiding Objects using CSS

Examples to hide the SEARCH box on a site, and more …

<style type="text/css">  
#DeltaPlaceHolderSearchArea {display: none;}
.ms-InlineSearch-SearchStatus {display:none;}
.ms-cui-topBar2 { display : none; }
</style> 

– Hiding Objects using JQuery, give the same effect.

– Hiding Objects using SharePoint Designer : See below

Tools :

1. SharePoint Designer

Hide Libraries from the all site contents

image

image

Use SP Designer Workflows to automate Security settings on Lists and Libraries or Records / Documents

See here for how to.

First activate the Workflows can use app permissions using Site Features

image

Go to Site Settings –> Site App Permissions

image

Copy this part of the GUID and insert it in

image

Go to the Site Collection URL and add this part  “_layouts/15/appinv.aspx”

Workflow App Permissions : See here for the extra steps to complete the whole process

2. PowerShell

Use PowerShell to automate Security settings on Lists and Libraries or Records / Documents

Or to create reports to get visibility on Security.

See here for some good examples

So if you combine all of them, you can go a long way !

But it is important that you have a good security strategy, before starting to build your application.

Enjoy !


PowerShell – Using PowerShell Script in Excel VBA

March 11, 2019

There are numerous real life scenarios where you would like to hand out an Excel to an End User to retrieve data straight in Excel.

Without him or her have to use PowerShell or any other obscure tool that does not look familiar to them.

So we can establish this by using the old time favorite tool from SAPIEN Technologies.

image

To download ActiveXPosh you need to register first …

This Free Tool is doing the magic between the PowerShell scripting and any COM compatible client, like Excel or VBScript or AutoIT Smile

So here we are going to create an Excel VBA macro to demonstrate the use.

Solution :

The flow being used is to export a PS script to CSV. And next open the data in the Excel file that runs the macro.

1. Make sure that you are using the correct architecture version x86 or x64, depending of your Excel architecture …

So if you use an Excel x86 version you need to install the x86 ActiveXPosh version.

2. Create a Excel + Macro using this script :

The PowerShell Script is :

Get-WmiObject -class Win32_Service | Export-Csv -Path c:\temp\temp.csv -NoTypeInformation

The complete VBA macro is :

 

Sub ActiveXPoSH_ExportPS_ImportCSV()

Const OUTPUT_CONSOLE = 0
Const OUTPUT_WINDOW = 1
Const OUTPUT_BUFFER = 2

Dim ActiveXPosh As Object
Dim success As Variant
Dim cmd As String
Dim file As String
Dim sheet As String

' see output location here
file = "C:\temp\temp.csv"
sheet = "Sheet1"

' create the PowerShell object
Set ActiveXPosh = CreateObject("SAPIEN.ActiveXPoSHV3")

success = ActiveXPosh.Init(vbFalse) 'Do not load profiles

If success <> 0 Then
    Debug.Print "Init failed"
End If

If ActiveXPosh.IsPowerShellInstalled Then
    Debug.Print "Ready to run PowerShell commands"
    'MsgBox ("Ready to run PowerShell commands")
Else
    Debug.Print "PowerShell not installed"
End If

'Set the output mode
ActiveXPosh.OutputMode = OUTPUT_CONSOLE

' set command string
cmd = "Get-WmiObject -class Win32_Service " _
      & " | Export-Csv -Path " & file & " -NoTypeInformation"

' clear all data
Sheets(sheet).Cells.Delete

Dim outtext, Str
' set the output mode to buffer
ActiveXPosh.OutputMode = OUTPUT_BUFFER

' run cmd
ActiveXPosh.Execute (cmd)

' get the output line by line and add it to a variable
For Each Str In ActiveXPosh.Output
    outtext = outtext & Str
    outtext = outtext & vbCrLf
Next

' import the data to the Sheet1
Set ws = ActiveWorkbook.Sheets(sheet)
With ws.QueryTables.Add(Connection:="TEXT;" & file, Destination:=ws.Range("A1"))
    .TextFileParseType = xlDelimited
    .TextFileCommaDelimiter = True
    .Refresh
End With

' delete the querytable if there is one
On Error GoTo nothingtodelete
    Sheets(sheet).QueryTables(1).SaveData = False
    Sheets(sheet).QueryTables.Item(1).Delete
nothingtodelete:

' Delete the temp CSV File
If Len(Dir$(file)) > 0 Then Kill file

' Alternatively you can get the output as a single String
' outtext = ActiveXPosh.OutputString
Debug.Print outtext

' Clear Immediate
Application.Wait (Now + TimeValue("0:00:02"))
Debug.Print Now
Application.SendKeys "^g ^a {DEL}"

End Sub

The result is :

image

I chose to work using an interim CSV file, because this is the fastest and most compatible with Excel. Smile

You can of course write cell per cell or an PowerShell array to Excel. But it will take you forever to make it happen. Sad smile

As you can imagine I can now get O365 and Azure data straight in Excel …

If you put a password on the macro you can safely hand it out in your organization !

 

Enjoy!


Write cache enabled Event ID 32 Error

March 11, 2019

After physical to Virtual conversion, we get this event ID 32 Error on a regular basis..

image

The driver detected that the device \Device\Harddisk0\DR0 has its write cache enabled. Data corruption may occur.

Solution :

See here : https://support.microsoft.com/en-ca/help/324805/how-to-manually-turn-disk-write-caching-on-or-off
Turn Disk Write Caching On or Off
  1. Right-click My Computer, and then click Properties.
  2. Click the Hardware tab, and then click Device Manager.
  3. Expand Disk Drives.
  4. Right-click the drive on which you want to turn disk write caching on or off, and then click Properties.
  5. Click the Policies tab.
  6. Click to select or clear the Enable write caching on the disk check box as appropriate.
  7. Click OK.
For Windows Server 2008
  1. Right-click Computer, and then click Properties.
  2. Click the Device Manager link under Tasks.
  3. Expand Disk Drives.
  4. Right-click the drive on which you want to turn disk write caching on or off, and then click Properties.
  5. Click the Policies tab.
  6. Click to select or clear the Enable write caching on the disk check box as appropriate.
  7. Click OK.

To find out the DISK number relation use this SysInternal tool, diskext.exe :

image

\Device\Harddisk0\DR0 = C drive

If you see the yellow exclamation mark saying you are not allowed to change the caching …

image

See here for more Information :

http://techgenix.com/hyper-v-optimization-tips-part1/

Enjoy!


Windows 2016 – Windows Update Center closes immediately

March 10, 2019

Opening the Windows Update Center closes immediately … ?

image

The main reason is that the Windows 2016 Software Distribution has become corrupted.

SOLUTION :

Clean the C:\Wndows\SoftwareDistribution folder…

See here for the procedure

https://www.windowscentral.com/how-clear-softwaredistribution-folder-windows-10

After this cleanup everything was back to normal

image