Computer info template/example (quick and dirty)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#WMI

$cred = get-credential

$computers = "test-www11", "test-www12"

$data = foreach ($computer in $computers) {
Get-WmiObject win32_operatingsystem -Credential $cred -ComputerName $computer |
Select-Object @{n="Name";e={$_.pscomputername}},
@{n="OS";e={$_.caption}},
@{n="Installed";e={$_.converttodatetime($_.installdate)}},
@{n="Uptime";e={(get-date) - $_.converttodatetime($_.Lastbootuptime)}},
OSarchitecture,
@{n="PS Version";e={(Invoke-Command -ComputerName $computer -credential $cred {$PSVersionTable.PSVersion.ToString()})}}

}

$data | Format-Table

#CIM

$computers = Invoke-Command -ComputerName mon-dc11 -Credential $cred {(Get-ADComputer -filter 'name -like "MON-*"' | where enabled -eq $true).name}

New-CimSession -ComputerName $computers -Credential $cred
$CS = Get-CimSession

$data = foreach ($computer in $computers) {
Get-CimInstance win32_operatingsystem -CimSession $cs|
Select-Object @{n="Name";e={$_.pscomputername}},
@{n="OS";e={$_.caption}},
@{n="Installed";e={$_.installdate}},
@{n="Uptime";e={(get-date)-$_.Lastbootuptime}},
OSarchitecture,
@{n="PS Version";e={(Invoke-Command -ComputerName $computer -credential $cred {$PSVersionTable.PSVersion.ToString()})}}

}

$data | Format-Table

Office 365 repair remotely with Powershell

1
2
3
4
5
6
7
$cred = Get-Credential
Enter-PSSession *computername* -cred $cred
cd 'C:\Program Files\Microsoft Office 15\ClientX64\'
.\OfficeClickToRun.exe scenario=Repair DisplayLevel=false RepairType=quickRepair forceappshutdown=true

# if quick repair did not solve it
.\OfficeClickToRun.exe scenario=Repair DisplayLevel=false RepairType=FullRepair forceappshutdown=true

Connect to Office 365 Powershell

1
2
3
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $cred -Authentication Basic -AllowRedirection

Import-PSSession $session

Unable to start OneDrive Windows 10

  1. Run gpedit.msc (Local Group Policy Editor)
  2. Next navigate to Computer Configuration\Administrative Templates\Windows Components\OneDrive.
  3. In the right panel, double click Prevent the usage of OneDrive for File Storage. Set it to Disable