Wednesday, March 23, 2016

OneDrive for Business usage report via Powershell


The solution below requires only SharePoint Online Management Shell :

1. Connect to Sharepoint Online:
Connect-SPOService -Url https://tenantname-admin.sharepoint.com

2. Get logins list you need to build report:

Ex. from existing Sharepoint Online tenant
$logins=(Get-SPOUser -Site https://tenantname-my.sharepoint.com).LoginName

or from external source Logins.csv
$logins = (import-csv logins.csv).Identity

where CSV-file content just like:
Identity
user1@domain.com
user2@domain.com
user3@domain.com
user4@domain.com
user5@domain.com

3. Build full usage report and export to CSV file:

foreach ($login in $logins) {
        if($Login.Contains('@')) {
        $login=$login.Replace('@','_');
        $login=$login.Replace('.','_');
        $login=$login.Replace('.','_');
        $login="https://tenantname-my.sharepoint.com/personal/"+$login;
        $Report = Get-SPOSite -Identity $login -ErrorAction SilentlyContinue
        $Report | Export-CSV ODFB-CSV-Report.csv -Append}  
        }

All pieces together in single PowerShell script:

# enter tenantname (ex. if appriver3651004263.onmicrosoft.com)
$tenant="appriver3651004263"

# Connect to Sharepoint Online:
Connect-SPOService -Url https://$($tenant)-admin.sharepoint.com

# Get logins list you need to build report: Ex. from existing Sharepoint Online tenant
$logins=(Get-SPOUser -Site https://$($tenant)-my.sharepoint.com).LoginName

# or from external source Logins.csv
# $logins = (import-csv logins.csv).Identity

foreach ($login in $logins) {
        if($Login.Contains('@')) {
        $login=$login.Replace('@','_');
        $login=$login.Replace('.','_');
        $login=$login.Replace('.','_');
        $login="https://$($tenant)-my.sharepoint.com/personal/"+$login;
        $Report = Get-SPOSite -Identity $login -ErrorAction SilentlyContinue
        $Report | Export-CSV ODFB-CSV-Report.csv -Append -NoTypeInformation}  
        }



Reference:
Create OneDrive for Business usage report using Powershell

Get companies list with their TenantID/Domain/Custom Domains/Company Name using CSP DAP

Use PowerShell script to get mapping between Company Name, TenantID, TenantDomain name "*.onmicrosoft.com" and CustomDomains.
You need to be connected with Office 365 using Partner account that has delegated access permission (DAP) to Cloud Solution Provider (CSP) Tenants prior to PowerShell script execution.

Get-MsolPartnerContract -All | select @{n="TenantID";e={$_.TenantID.tostring()}} | `
Get-MsolCompanyInformation  -ErrorAction SilentlyContinue | `
select ObjectId, InitialDomain, DisplayName, TechnicalNotificationEmails, `
@{Label="CustomDomains";e={Get-MsolDomain -TenantId $_.ObjectId -ErrorAction SilentlyContinue | ? IsInitial -ne $true | select -expandproperty name}}

Thursday, March 17, 2016

Windows admin quick notes for SCOM agent installation on Linux/UNIX

scxadmin -status
/opt/microsoft/scx/bin/tools/scxadmin -stop
/opt/microsoft/scx/bin/tools/scxadmin -start
/opt/microsoft/scx/bin/tools/scxadmin -restart


[root@hostname opsmgrsvc]# iptables --list
bash: iptables: command not found

Add /sbin to your path by editing your ~./bash_profile:
user $ vi ~/.bash_profile

Append /sbin to the PATH definition. In my file, this looks like:
PATH=$PATH:$HOME/bin –> PATH=$PATH:$HOME/bin:/sbin

Save and close ~/.bash_profile
$ ESC + :wq

Reload ~/.bash_profile: user
$ source ~/.bash_profile

No save: ESC+:q!

Allow tcp port 1270 inbound from 172.16.5.0/24 subnet:
iptables -I INPUT -p tcp -m tcp -s 172.16.5.0/24 --dport 1270 -j ACCEPT
service iptables save


vi /etc/hosts

NXT01:/etc/snmp # uname –a
Linux NXT01 2.6.18.2-34.nx26-bigsmp #1 SMP Mon Nov 27 11:46:27 UTC 2006 i686 i686 i386 GNU/Linux

NXT01:/etc/snmp # cat /proc/version
Linux version 2.6.18.2-34.nx26-bigsmp (geeko@buildhost) (gcc version 4.1.2 20061115 (prerelease) (SUSE Linux)) #1 SMP Mon Nov 27 11:46:27 UTC 2006

cat /etc/*release

SuSE Linux 9.1 (i586)

VERSION = 9.1

SCOM cannot discover Linux or UNIX based host with "Unspecified failure"

Issue:
SCOM cannot discover Linux or UNIX based host and reports error:


Unexpected DiscoveryResult.ErrorData type. Please file bug report.
ErrorData: Microsoft.SystemCenter.CrossPlatform.ClientLibrary.Common.SDKAbstraction.TaskInvocationException
Task invocation failed with error code -2130771857. Error message was: 0x80FF006F
at System.Activities.WorkflowApplication.Invoke(Activity activity, IDictionary`2 inputs, WorkflowInstanceExtensionManager extensions, TimeSpan timeout)
at System.Activities.WorkflowInvoker.Invoke(Activity workflow, IDictionary`2 inputs, TimeSpan timeout, WorkflowInstanceExtensionManager extensions)
at Microsoft.SystemCenter.CrossPlatform.ClientActions.DefaultDiscovery.InvokeWorkflow(IManagedObject managementActionPoint, DiscoveryTargetEndpoint criteria, IInstallableAgents installableAgents)


Resolution:
There are 2 possible reasons of this problem:

  • "WS-Management Action Account" profile can contain "Run As Account" with wrong scope something like "All targeted objects"
  • Some users reported they've used special characters like "&" in account password used for Linux/UNIX host discovery
References: