Home

Windows PowerShell

45 Conversations

Latest Activity

Custom List Message Item

Hi,

 

Disclaimer: I am new to PowerShell, hence why I turn here for your input.

 

Background:

I'm creating a Power BI dashboard based on data exported from the O365 Audit Log. For the moment, I'm not using the recently launched API, but a daily scheduled Power

... Read More
503 Views
14 Replies

Have you checked the parameter "SessionCommand" in the Search-UnifiedAuditLog cmdlet?. By using this you can get all the records. But you need to do the filters in the DB

... Read More

What you are looking for I guess is something like a "NOT" operator, which will allow you to exclude all actions from particular user/account. Unfortunately, I'm not awar

... Read More

Hi guys,

 

Can someone tell me what is wrong with attached script. When I change my own tenant settings and run this, I got below error. I have gone it trought a dosens of times and I just can't see what I'm missing.

 

I am running this script on SPO shell an

... Read More
56 Views
4 Replies

Hi Anna-Maria,

 

You have a problem with encoding where a few dashes (-) are replaced with the text –. This usually happens when copying and pasting text between differen

... Read More

Hi,

Here i attached modified script,  it will solve your issue.

i need to export users in powershell with centricaplc.onmicrosoft.com domain and are licenced

 

i tried this command doesnt work

 

Get-MsolUser -All | Where-Object {$_.Domain -eq "centricaplc.onmicrosoft.com"} | Export-CSV c:\support\cloud.csv

 

i tried doing

... Read More
97 Views
4 Replies

You can try this script

 

Get-MsolUser -All |Where-Object {$_.UserPrincipalName -like "*centricaplc.onmicrosoft.com" -and $_.isLicensed -eq $true } |Export-csv c:\support\c
... Read More
Best Response

You are comparing against a "domain" property, which does not exist. Try something like this instead:

 

Get-MsolUser -All | ? {$_.UserPrincipalName.Split("@")[1] -eq "centr

... Read More

I got this from someone, and for Albania it works like it should. But if i change to for example Germany as country, it gets text and not the correct dates in the date collum.  I see that with Germany and some other countries also have a publicholiday and

... Read More
52 Views
2 Replies

 Try below script and it will work more most country Like USA,INDIA,germany but it will not work for albania.

 

$uri = 'http://www.officeholidays.com/countries/usa/index.ph
... Read More
Best Response

Hello everyone,

 

Are you using code review in your team ? (i do but still got a lot of questions)

 

* Do you use a guideline? like this one (by Mike Shepard)?

 

* Do you use PowerShell/PSScriptAnalyzer in your code review?

 

* What's your process if you have one

... Read More
93 Views
2 Replies

We use PSScriptAnalyser with custom rules and Pester Unit tests. On commit to GIT we check that Test are good and Code Coverage is high. Check out any of Microsoft DSC Re

... Read More
Well I'm a Steroids user so I get that taken care of. But I agree with Mike Shepard that scripts that are anything but private should maintain a high level of readability... Read More

Hello

I have a windows PowerShell Script that I made to move a folder to anther folder on the same drive. (move-item 'E:\System State Folder' 'E:\Backup Folder') Action : Start a Program, Program/script: PowerShell, Add arguments: -ExecutionPolicy Bypass,

... Read More
85 Views
6 Replies

And you might also need to run the script as administrator. In any case, add some logging/debugging capabilities in the script in order to troubleshoot it properly.

Read More

how to i add export command to the below script

 

$siteURL = "https://litwareinc.sharepoint.com/sites/finance"
$x = Get-SPOSiteGroup -Site $siteURL
foreach ($y in $x)
    {
        Write-Host $y.Title -ForegroundColor "Yellow"
        Get-SPOSiteGroup -Site
... Read More
108 Views
6 Replies

Try this script

 

$siteURL = "https://litwareinc.sharepoint.com/sites/finance"
$x = Get-SPOSiteGroup -Site $siteURL
$GroupList = @()


foreach ($y in $x)
    {
       
    
... Read More

How about:

 

($siteURL = "https://litwareinc.sharepoint.com/sites/finance"
$x = Get-SPOSiteGroup -Site $siteURL
foreach ($y in $x)
    {
        Get-SPOSiteGroup -Site $sit
... Read More
Best Response

You might want to give a bit more detail on what you are trying to do? Do you want to export the output to an .txt file?

I have a powershell script that loops a fileshare and reports the properties of all the files.

This part reports to a .txt file:

Get-ChildItem -Recurse $source |  ?{-not $_.PSIsContainer} | ForEach-Object {Audit-File $_} | Sort-Object fullname | Select Full
... Read More
113 Views
4 Replies

Try this script for output with txt file

 

$Details=Get-ChildItem -Recurse $source |  ?{-not $_.PSIsContainer} | ForEach-Object {Audit-File $_} | Sort-Object fullname | Sel
... Read More
Best Response

Use the -Encoding parameter with Export-CSV, it works just fine. For example:

 

Export-Csv -NTI blabla.csv -Encoding Unicode

Disclaimer - Limited Powershell experience and new to the community

 

We've developed a script that runs on our local machines that pull O365 audit logs using the commandlet Search-UnifiedAuditLog 

Our local machines have:

Windows 10 64 bit with Powershell 5 

... Read More
86 Views
3 Replies

The cmdlet is loaded via Remote PowerShell, so nothing specific is needed on the machine. Are you actually able to connect to SCC PowerShell on said machine? Can you use

... Read More
Best Response

Hi Team ,

 

I need immediate help in getting the tutorial for course number - 6434 (Automating Windows Server 2008 Administration with Windows PowerShell) , exam reference number - 83-640 .

 

I know this course has been retired . But I wanted to learn .

 

Pleas

... Read More
58 Views
1 Reply
This is a great, FREE intro to PowerShell By Jeffery Snover and Jason Helmick https://mva.microsoft.com/en-US/training-courses/getting-started-with-microsoft-powershell-8276

... Read More

I found a very good article on Powershell which will give us the complete idea to automate certain things in Active Directory .

 

To know more details , check this link .

 

https://mva.microsoft.com/en-us/training-courses/using-powershell-for-active-directory-8397?l=iUERrJJz_7204984382#

... Read More
73 Views
0 Reply

Hello, 

I wanted to know if there is a script that can send an email when an event is log

82 Views
2 Replies
There plenty of these, just choose :) one of the examples https://gallery.technet.microsoft.com/PowerShell-Script-to-Send-873dc0b6 Read More

Hi

 

I need to move data from one attribute to another on a user object in Active Dirctory.

 

Today the attribute homePhone is porpulated with users private mobile number. I need to move this to otherMobile.

 

First I try to do this on my own account this way:

$

... Read More
116 Views
4 Replies

Hi
Otherhomephone is multivalue attribute so that it is not working and you can try below script

$users = get-aduser -Filter * -Properties *|Where-Object {$_.otherhomePhone
... Read More
Best Response

Please use the below script and check.

 

$users = get-aduser -Filter * -Properties *|Where-Object {$_.homePhone -ne $null }| Select-Object Samaccountname,homePhone

foreach
... Read More

I have a azure web job in C# where i am trying to connect to SPO through connect-sposervice. I have copied the complete Sharepoint online management shell folder from my local into my project and uploaded but still i get the error in web job 

 

D:\home\site
... Read More
158 Views
9 Replies
It can be tricky to use the SPOnline module from a webjob as it has a lot of associated binaries, one option could be to trigger an associated Azure Automation script usi... Read More

I am trying to remove some services from users.  I have the following script:

 

$ApprovedPlans="EXCHANGE_S_ENTERPRISE","SHAREPOINTENTERPRISE","SHAREPOINTWAC","MCOSTANDARD","OFFICESUBSCRIPTION","RMS_S_ENTERPRISE","YAMMER_ENTERPRISE"
$AccountSkuID = (Get-MsolA

... Read More
116 Views
6 Replies

You should be covering two scenarios:

 

1) The user already has the same license applied, so only provide the LicenseOptions

2) The user does not have this license applied,

... Read More

I currently use the below script to connect to the S&C Center. This does not work with MFA.

I was wondering if there is an Updated Module that I could use that supports modern authentication?

 

$Credential = get-credential -Credential username.com

 

$Session =

... Read More
206 Views
2 Replies

Nope, not yet. It's the last of the "modules" I use to get MFA support :(

Best Response

Hi all,

 

I have a quick query, that I'm hoping someone might be able to help me with.

 

I run a number of powershell scripts weekly (Inactive accounts, DA memebers, etc) and the output of each script is emailed to my IT colleagues in either EXCEL or html for

... Read More
132 Views
2 Replies
A quick and easy solution (depending on your security and other requirements) might be to run up an IIS web service and turn on directory browsing, then use convertto-htm... Read More
Best Response

Im using the following code to add properties to an object

 

$ten = Get-MsolCompanyInformation -TenantId $tenantItem
$objTenantData = New-Object -TypeName system.object
$objTenantData | Add-Member -Type NoteProperty -Name AuthorizedServiceInstances -value $
... Read More
81 Views
1 Reply
I am assuming that the Add-member line is just one of many you want to add to the $objTennantData object and that you want the string array added as a single value (let m... Read More
Best Response

Hi All

 

I have long running scripts running against O365 for our tenant. These can take a day or two to complete.  During the run of the script, there can be an interuption where the credentials manager popup requests the credentials again, despite me havi

... Read More
186 Views
4 Replies

Hello,

 

I'm using this one and works great for me : 

 

Set-ExecutionPolicy RemoteSigned
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsof
... Read More

That's just a side effect of broken session to Exchange Online and PowerShell's attempt to recconect to it. The best thing you can do is to optimize your script to run as

... Read More
Best Response

Hi,

 

I'd like to be able to manage all of our client Office 365 tenants via PowerShell.

 

However when I try to login to PowerShell using the global admin account credentials, this does not allow me to login to PowerShell.

 

What's the best wasy for me to do w

... Read More
105 Views
2 Replies

Hi,

 

You can try this code, it works for me : 

 

Set-ExecutionPolicy RemoteSigned
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exch
... Read More

Greetings,

 

We need to know a little more details, such as the error you are getting, what command you have tried, etc.  There is a little setup required such as installin

... Read More

Hello, I have set up a virtual machine using the Windows 10 trial VM for Hyper-V (https://developer.microsoft.com/en-us/microsoft-edge/tools/vms/, preview 15.15). I would like to use Powershell Direct to run Powershell scripts on my VM. I believe I've suc

... Read More
82 Views
1 Reply

I managed to resolve the issue. I updated the hyper-v configuration for the vm from 5 to 8. I then used the credential "Host computer name"\IEUser  with password Passw0rd

... Read More

Anyone got a explanation why this is happening? Also tried with " around the text in the input.

Read-host seems to work if i only input one thing like: Sway

Not working when inputting: sway,yammer_enterprise

 

1.PNG2.PNG4.PNG

Read More
126 Views
3 Replies

You're passing a String value, it needs to be list. Try it like this:

 

$newSKU = New-MsolLicenseOptions -AccountSkuId tenant:SKUID -DisabledPlans $SelectedPlans.Split(",")

Read More

Found it out, had to do it like this.

5.PNG

 

Read More
Best Response

I want to use PowerShell to export the most recent week's worth of Admin Message Center Messages to a spreadsheet because I want to annotate each item with what I am planning to do about each announcement. #Governance

 

I have an account for this purpose th

... Read More
301 Views
7 Replies

Hi Michael,

The v2 API (preview) requires that you register the script/app.  One immediate term option is to use the non-preview v1 API.  Sample code may be found here (

... Read More

Hello Everyone,

 

If you could share few videos which will easily make understand of the windows powershell better for server admin 

91 Views
1 Reply