net System error 2240 has occurred The user is not allowed to log on from this workstation error in PowerShell SharePoint Online

This PowerShell tutorial, how to resolve net System error 2240 has occurred The user is not allowed to log on from this workstation error in PowerShell SharePoint Online.

Recently we got one requirement to copy documents from shared drive to a SharePoint online document library using PowerShell. In that PowerShell command, we were providing the shared drvie ip address, username, and password. And then we were using the net use command like below:

$fileDirectory="\\IP Address\FolderName"
$username = "Domain\Username"
$password = "Password"
net use $fileDirectory $password /USER:$username

But in the above line it was giving the below error:

net : System error 1219 has occurred.
At C:\Users\Bijaya.Sahoo\Desktop\laregefileupload.ps1:45 char:1
+ net use $fileName $password /USER:$username
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (System error 1219 has occurred.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError

The user is not allowed to log on from this workstation.

The full error looks like below:

The user is not allowed to log on from this workstation
The user is not allowed to log on from this workstation

net System error 2240 has occurred

Here first thing you need to check is the domain name should be same (workstation and shared drive one).

If you are using a vpn, then you can execute the code outside of the vpn.

Read some SharePoint PowerShell tutorials:

If both the things did not work, you can check with your admin team, if they have put any restrictions.

>