Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all 15028 articles
Browse latest View live

[Import-Csv], UnauthorizedAccessException

$
0
0

Hey guys, I have an issue when trying to use the Import-CSV command.

Scenario: I'm running a script that imports a csv file from a network share. This script is running off of a SharePoint Server. It will take the contents of that csv and import it into a list on our SharePoint Server. I am running this script remotely, it works if I am remoted into the SharePoint Server from a PSSession and type the command in as follows: Import-Csv "\\server\share\share\$filename.csv". It just doesn't work inside the script. Also, I have verrified the credentials have access to this netowrk share. Any help would be greatly appreciated. Thanks in advance.

Here is the relevant part of the script
add-PSSnapin Microsoft.SharePoint.PowerShell
$filename = read-host "Please enter the Name of the File"

$contents = Import-Csv "\\server\share\share\$filename.csv"
$web = Get-SPWeb -Identity ‘http://Server/'
$list = $web.Lists["SharePointList"]

Here is my output containing the error message
Cannot open file "\\server\Share\Share\Filename deposits.csv".
    + CategoryInfo          : OpenError: (:) [Import-Csv], UnauthorizedAccessException
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ImportCsvCommand


Code Access Security - PowerShell

$
0
0

Goal:

I want to be able to use CAS features to prevent users from executing certain blocks of code in my script.

For example:

How do I prevent user 'network\zmurphey' from executing this code in posh?

function Get-FooBar {
$key = 123
$results = Invoke-WebRequest -method GET -uri foobar.com -Headers @{key = $key}
$results.table
}

And,

Will this user be affected across the entire module? Meaning, will he be able to execute other functions in the same module?

Powershell: How to compare short dates (mm/dd/yyyy) as dates rather than as strings?

$
0
0

Hi,

I have several scripts that compare today's date to the last day of each quarter to determine what file to log things to and whether or not end-of-quarter e-mails should be sent out.

I need to compare today's date with that of the last day of the quarter.  I know that by default "Get-Date" will return a long date with time (e.g. Monday, October 04, 2010 10:24:22 AM), which is of the typeSystem.DateTime .  This works for date comparison, but doesn't suit my needs.

I know that I can change the format of the date to "10/4/2010" by using "Get-Date -Format d".  The problem is that this returns a result of the type toSystem.String , which doesn't work for date comparison.

I would very grateful for any help.


Thank you.

Importing CSV Returns Error

$
0
0
$Path = 'C:\users\user\adusers.csv'

$users = Import-CSV $Path

foreach ($user in $users) {
$Sam = Get-ADUser $user | fl samaccountname
$RPP = Get-ADUserResultantPasswordPolicy $sam
if ($RPP -ne $null)
{
write-host "$user has a PSO"
}
else {
write-host "$user doesn't have a PSO"
}
}

I am having issues importing this CSV. If I manually build the array with users, it works fine. If I import the CSV I get an error as seen below:

Get-ADUserResultantPasswordPolicy : Cannot bind parameter 'Identity". Cannot convert value "@{samaccountname=user}" to type "Microsoft.ActiveDirectory.Management.ADUser".

The objective of the script is to import users stored like in individual rows, determine if they have any return when Get-ADUserResultantPasswordPolicy runs with their username (auser) and then to eventually put it into a new csv for viewing.

Like I said, if I create my own array #$users = $("test", "user", "bill", "john") it will work. It only breaks on import of the CSV.

How to change Windows display language and keyboard layout?

$
0
0
Hi,

it's been many days now that I'm looking for a way to change the display language and the keyboard layout with a powershell script :/ 

Searching on google, all the answers say always to do:

Set-WinUserLanguageList en-GB

but that's not what I need. It changes the profile to english, but even after a logoff and login, the displayed language is still the previous one. Only the keyboard input changed (which is the only thing I want to keep the way it is).

I live in France, so I have to use french keyboards when I work, but I want to change all my system language in english (UK). It's easy to do with the GUI, but I would like to be able to do in with a PowerShell script.


This is my current script to do this:


# Import 'International' module to PowerShell session. I'm not sure it's really important
Import-Module International

# Set regional format (date/time etc.) to English (United Kingdom) - this applies to all users. It's important for calendar, to see it in english instead of french
Set-Culture en-GB

# Set the display language for the user, forcing English (United Kingdom)
Set-WinUserLanguageList en-GB -Force

# Logoff to apply the settings
logoff



And it doesn't work. I need a script that download the english language (since it's not already in the system), then set it as default language for everything EXCEPT the keyboard, which has to stay in french. How can I fix it?


Thank you in advance :)

Use Filter attribute with Get-Content

$
0
0

I'm trying to figure out the proper syntax to apply the -Filter attribute in conjunction with a Get-Content cmdlet. 

I've tried several variations of Get-Content -Path myfile.txt -Filter mystring and I get an error message. How is this supposed to work?  I have not found any example anywhere.

Thanks.

Script to check if DLL is being loaded by a process

$
0
0

Hello everyone,

I would like some help from you.

I need to create a script that checks whether a given DLL was "loaded" by a process. To understand, for example, taking into account the image below, we will think that I want to know if the DLL that is selected at the bottom of the image is being"loaded" by the process that is selected at the top of the image below;

I checked several WMI objects (including Win32_Process) and just found the process, I got to see an object (I can not remember the name now) WMI that showed some DLLs, but not the ones that are being "loaded" by a process.

Anyone have any idea how I can create a script that checks this? Which WMI object could give me this information?

Sorry for any translation failures (by google).

How to pass file names with spaces is parameters?

$
0
0

I must have read 20 threads on handling spaces in file names, and still do not have a solution.  I've used ampersands, backticks, combinations of double and single quotes, and still can't get the simple script shown below to work with paths/filenames which have spaces.  The PS script below calls the ImageMagick "convert" command.  But when I call the script like this:

IM-append.ps1 C:\Users\bernie\Photo Staging\file1.jpg, C:\Users\bernie\Photo Staging\file2.jpg

It chokes on the space in the "Photo Staging" directory.  Note that the file names need to be comma separated.  How can I pass these file names/paths with spaces?

IM-append.ps1:

param(
[  string[]]$fnames
)

convert $fnames -append merged-vertical.jpg


Automate file download from Website using powershell weekly

$
0
0

Hey Everyone,

i am new to Powershell and i need help creating a script which can download a file "WA$date"

the website is https:/XXXX/WA$date

and it requires a passwd & username before download.

this file will be dumped in a folder T:/XXX 

please any suggestions? Thank You!!


QNN


Compare XML Values on Element Match

$
0
0

Having issues figuring this one out on my own.  I need to compare 2 xml files say a baseline.xml and a compare.xml using PowerShell.  Both of these files will have a list of file names using full path and a file hash.  I need to get one object, FilePath, from the compare.xml and search the baseline then compare the hash, if there is a difference not this in an array for later use.  Below are the XML files examples.

Baseline.xml

<FileChecks><!--Created: 2/2/2017 8:47 PM on AJBDEV-PRIME--><File FilePath="D:\test\bfsvc.exe" Hash="BE379B732A8A9C15A0F5D99933A695CEE6F4382D30975DB9D48D4FE4F9E73530FFC88C285692F6BDF5BF0F1EBE90A9ECF68AA40228A27CB1059461C555B697C6" /><File FilePath="D:\test\explorer.exe" Hash="877AC7A9DD81E53A994F233BFAB9EB828287E7C89B5DC424FC12DEB3C777ACCE7916627220B44F5E0F3A0C07DCC8319E7A843462865C0431DEEE79B58FAF9101" /><File FilePath="D:\test\HelpPane.exe" Hash="ECC3E15EA6AC2C02535BE78F525F192776FF18AC7D70E441C220290C58668C8FD9B4422ADC75B0FAFD8114E11D301BC7DF2D96B2C718D6464B1F53C7894268AB" /></FileChecks>

Compare.xml

<FileChecks><!--Created: 2/2/2017 8:47 PM on AJBDEV-PRIME--><File FilePath="D:\test\bfsvc.exe" Hash="BE379B732A8A9C15A0F5D99933A695CEE6F4382D30975DB9D48D4FE4F9E73530FFC88C285692F6BDF5BF0F1EBE90A9ECF68AA40228A27CB1059461C555B697C6_DIFFERENT" /><File FilePath="D:\test\explorer.exe" Hash="877AC7A9DD81E53A994F233BFAB9EB828287E7C89B5DC424FC12DEB3C777ACCE7916627220B44F5E0F3A0C07DCC8319E7A843462865C0431DEEE79B58FAF9101" /><File FilePath="D:\test\HelpPane.exe" Hash="ECC3E15EA6AC2C02535BE78F525F192776FF18AC7D70E441C220290C58668C8FD9B4422ADC75B0FAFD8114E11D301BC7DF2D96B2C718D6464B1F53C7894268AB_DIFFERENT" /></FileChecks>

Any examples would be helpful.

Thanks



How to do real time input validation in a datagridview control

$
0
0

Team,

I've been working on a form for standard user account creation that I want to make stringent rules on how they are created. Right now, all I've got is some validation checking when the "Create users" button is clicked so that it generates some pop ups if there are errors, but I'm certain there's a way to handle it once the focus is changed or the user tabs out of the box, but I've tried the "CellValidating" event and the "CellFormatting" event, but nothing seems to happen after it changes focus. Not sure what is going on. Below is the code and I really appreciate the help.

$buttonCreateUsers_Click = {
	# Subtracting one from row count so it doesn't try to use the last blank row created during run time operations
	$rowcount = $datagridviewResults.RowCount - 1

	for ($i = 0; $i -lt $rowcount; $i++)
	{
		$EDIPIRegex = "^\d{10}$"
		$EnteredEDIPI = $datagridviewResults.Rows[$i].Cells['EDIPI'].Value
		if ($EnteredEDIPI -notmatch $EDIPIRegex) { [System.Windows.Forms.MessageBox]::Show("EDIPI for $DisplayName must be 10 numeric digits", "Error") }

		$DisplayName = $datagridviewResults.Rows[$i].Cells['LastName'].Value + ", " + $datagridviewResults.Rows[$i].Cells['FirstName'].Value + " " + $datagridviewResults.Rows[$i].Cells['Rank'].Value + " " + $datagridviewResults.Rows[$i].Cells['Title'].Value + " " + $datagridviewResults.Rows[$i].Cells['Organization'].Value
		$GivenName = $datagridviewResults.Rows[$i].Cells['FirstName'].Value
		$Surname = $datagridviewResults.Rows[$i].Cells['LastName'].Value
		try { [datetime]$AccountExpiration = $datagridviewResults.Rows[$i].Cells['ExpirationDate'].Value }
		catch { [System.Windows.Forms.MessageBox]::Show($_.Exception.Message + ". Please check Account Expiration Date format for $DisplayName. Try the format m/d/yyyy", "Error") }
		$UPN = $datagridviewResults.Rows[$i].Cells['EDIPI'].Value + "@mil"
		$MidInit = $datagridviewResults.Rows[$i].Cells['MI'].Value
		if ($MidInit -ne $null) { $SamAccountName = "$GivenName.$MidInit.$Surname" }
		else {$SamAccountName = "$GivenName.$Surname"}
		$Name = $DisplayName
		$UserDescription = $datagridviewResults.Rows[$i].Cells['Description'].Value
		try { New-ADUser -DisplayName $DisplayName -GivenName $GivenName -Surname $Surname -UserPrincipalName $UPN -SamAccountName $SAMAccountName -Name $DisplayName -Path "OU=SYS,OU=CTR,OU=Users,OU=HD_JAMO,OU=JNCC-A,DC=afghan,DC=swa,DC=ds,DC=army,DC=mil" -SmartcardLogonRequired $true -Description $UserDescription }
		catch { [System.Windows.Forms.MessageBox]::Show($_.Exception.Message + ". Please check that first.m.last does not exceed 20 characters or that '$DisplayName' does not exceed 64 characters'", 'Error')}
	}

The code above is for the Create user button Click event. Below is for the CellValidating event, which I thought should be taking place on the "EDIPI" column.

$datagridviewResults_CellValidating=[System.Windows.Forms.DataGridViewCellValidatingEventHandler]{
#Event Argument: $_ = [System.Windows.Forms.DataGridViewCellValidatingEventArgs]
	#TODO: Place custom script here
	for ($i = 0; $i -lt $rowcount; $i++)
	{
		$EDIPIRegex = "^\d{10}$"
		$EnteredEDIPI = $datagridviewResults.Rows[$i].Cells['EDIPI'].Value
		if ($EnteredEDIPI -notmatch $EDIPIRegex) { [System.Windows.Forms.MessageBox]::Show("EDIPI must be 10 numeric digits","Error")}
	}
}

I appreciate any help.

Get-AzureRmRecoveryServicesBackupContainer : Requested value 'NotRegistered' was not found

$
0
0

I am using below command in Azure Automation Powershell script to get status of Recovery Services container - it simply checks if a VM is registered for backup.

Get-AzureRmRecoveryServicesVault -Name $AzureRecoveryServicesName | Set-AzureRmRecoveryServicesVaultContext
$BackupStatus = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureVM -FriendlyName $VirtualMachineName -ResourceGroupName $ResourceGroupName
If a VM is not registered it throws an error and $BackupStatus is empty:

Get-AzureRmRecoveryServicesBackupContainer : Requested value 'NotRegistered' was not found.

At line:53 char:21

  • ... kupStatus = Get-AzureRmRecoveryServicesBackupContainer -ContainerType ...

  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    • CategoryInfo : InvalidArgument: (:) [Get-AzureRmReco...BackupContainer], ArgumentException

    • FullyQualifiedErrorId :

Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.GetAzureRmRecoveryServicesBackupContainer

And if it is already registered I get $BackupStatus = Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.AzureVmContainer. I've tried:

$BackupStatus = (Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureVM -FriendlyName $VirtualMachineName -ResourceGroupName $ResourceGroupName).Status
But then the only difference is that I get $BackupStatus = Registered when VM is already in a container but same error occurs when VM is not registered.

What is the proper way to check if a VM is registered for backup or not? I am ok with what I'm getting - I can handle $BackupStatus values in a script - but I don't want this error message to show.

Strange thing is that in Powershell on PC with same Azure modules versions loaded (AzureRM​.RecoveryServices​.Backup 2.5.0) as in Automation Account I am getting a different behavior:

PS C:\windows\system32> $BackupStatus = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureVM -FriendlyName $VirtualMachineName -ResourceGroupName $ResourceGroupName
PS C:\windows\system32> $BackupStatus

        Name                                     ResourceGroupName                        Status               ContainerType
        ----                                     -----------------                        ------               -------------
        UbuntuBckptest                           rhel68128                                Registered           AzureVM
It returns an object instead of a string.


Script powershell to export a vm and delete the oldest folder

$
0
0

Hi everyone!

I'm creating a script in powershell  to export a virtual machine and delete the oldest folder.

So, we need to run this script everyday and we need to keep just two folders of the exportation.

I'm not an expert in scripting and if someone can help me it will be so good.

Let me explain my "Logic"
 The script will export the virtual machine into the $basedir and the variable $today is to save the folder name with the date.
 The second part is to delete the oldest folder into the $basedir
 The third part is to export the VM
   - This part is not right, i Can export the VM, but i put the variable $today to insert the date with the name of the exportation. I mean "i have a vm called 'VM01' and after the export i would like that folder changes for VM01DATA 'VM01020217'

Can you help me please?

$basedir = "H:\TEST\VM-01\"
$today= (Get-Date).ToString('mm_dd_yyyy')

Get-ChildItem $basedir |
sort-Object { $_.Name -as [Version] } |
Select-Object -Last 1 |
Remove-Item

$location = New-Item -Path $basedir -Type Directory -Name $today
Export-VM -name VM-01 -Path H:\TEST\VM01 + $today


Na vida há dois caminhos mais só um que vai na direção certa

VBS modify account status in AD

$
0
0

hello

here is a part of a script in a procedure where I try to modify the status of an account in the AD. I just try to unlock it. But as you will remark, the system doesn't allow me this task read/write because of the accounts. Can someone tell me how to proceed ? Again this a only a part of a script.


  'name is the path access to the concerned account
'name = "CN=" &user &",OU=" &access &",OU=USERS,OU=HOME,DC=domain,DC=pri"
Sub unlock(name) 
    Const ADS_USE_ENCRYPTION = 2
    Const ADS_SECURE_AUTHENTICATION = 1
    
    strUsername = "xxx"
    strPassword = "xxxx"
    
    Set objUser = GetObject _
      ("LDAP://" &name &" , " &strUsername &" , " &strPassword, ADS_USE_ENCRYPTIONOR ADS_SECURE_AUTHENTICATION)
     '("LDAP://" &name)

    
    
    objUser.IsAccountLocked = True
    objUser.SetInfo
    
    MsgBox"" &name &" unlocked"
EndSub


Unable to run automated tasks with reboot due to bitlocker

$
0
0

Hi,

I run several VBScripts and windows batch files. I cannot find a command to run for either as an administrator on the local computer that will reboot the machine and not prompt the user for a bitlocker pin when it starts back up. This is needed as i have a job that runs that needs a reboot to continue with several tasks post reboot. Does anyone know if this is achievable as an admin using wither VBScript or a windows batch file? If so, how?

Regards,

Vishay


Use Powershell to set Print Spooled Documents First

$
0
0

How do set print spooled documents first using a powershell script?

Powershell and PDF using itextsharp

$
0
0

I am working with success in reading PDF files using the itextsharp.dll.

Below the code fragment, which does this little miracle:

Add-Type -Path $ItextSharp<mytubeelement data="{"bundle":{"label_delimitor":":","percentage":"%","smart_buffer":"Smart Buffer","start_playing_when_buffered":"Start playing when buffered","sound":"Sound","desktop_notification":"Desktop Notification","continuation_on_next_line":"-","loop":"Loop","only_notify":"Only Notify","estimated_time":"Estimated Time","global_preferences":"Global Preferences","no_notification_supported_on_your_browser":"No notification style supported on your browser version","video_buffered":"Video Buffered","buffered":"Buffered","hyphen":"-","buffered_message":"The video has been buffered as requested and is ready to play.","not_supported":"Not Supported","on":"On","off":"Off","click_to_enable_for_this_site":"Click to enable for this site","desktop_notification_denied":"You have denied permission for desktop notification for this site","notification_status_delimitor":";","error":"Error","adblock_interferance_message":"Adblock (or similar extension) is known to interfere with SmartVideo. Please add this url to adblock whitelist.","calculating":"Calculating","waiting":"Waiting","will_start_buffering_when_initialized":"Will start buffering when initialized","will_start_playing_when_initialized":"Will start playing when initialized","completed":"Completed","buffering_stalled":"Buffering is stalled. Will stop.","stopped":"Stopped","hr":"Hr","min":"Min","sec":"Sec","any_moment":"Any Moment","popup_donate_to":"Donate to","extension_id":null},"prefs":{"desktopNotification":true,"soundNotification":true,"logLevel":0,"enable":true,"loop":false,"hidePopup":false,"autoPlay":false,"autoBuffer":false,"autoPlayOnBuffer":false,"autoPlayOnBufferPercentage":42,"autoPlayOnSmartBuffer":true,"quality":"default","fshd":false,"onlyNotification":false,"enableFullScreen":true,"saveBandwidth":false,"hideAnnotations":false,"turnOffPagedBuffering":false}}" event="preferencesUpdated" id="myTubeRelayElementToPage"></mytubeelement>

$reader = New-Object iTextSharp.text.pdf.pdfreader -ArgumentList $TestPDF

for ($page = 1; $page -le $reader.NumberOfPages; $page++) {
  $lines = [char[]]$reader.GetPageContent($page) -join "" -split "`n"
   foreach ($line in $lines) {
     $line
   }
}

I want to do nicer things however, and here come my question:

In order to understand better the dll at hand I try the following:

$asm = [Reflection.Assembly]::LoadFile($ItextSharp)
$asm.GetTypes() | select Name, Namespace | sort Namespace | ft -groupby Namespace

but how do I arrive the the methods and object defined in the dll without desecting the C# code ? unfortunately the dll does not come with a lot of documentation, so I would like to use Powershell board tools to explore what I have in the dll file.

Question I have are: how do I know from the dll that the object I want to create is:iTextSharp.text.pdf.pdfreader ?

Thank you very much for any hint

Yours

Erich

<mytubeelement data="{"bundle":{"label_delimitor":":","percentage":"%","smart_buffer":"Smart Buffer","start_playing_when_buffered":"Start playing when buffered","sound":"Sound","desktop_notification":"Desktop Notification","continuation_on_next_line":"-","loop":"Loop","only_notify":"Only Notify","estimated_time":"Estimated Time","global_preferences":"Global Preferences","no_notification_supported_on_your_browser":"No notification style supported on your browser version","video_buffered":"Video Buffered","buffered":"Buffered","hyphen":"-","buffered_message":"The video has been buffered as requested and is ready to play.","not_supported":"Not Supported","on":"On","off":"Off","click_to_enable_for_this_site":"Click to enable for this site","desktop_notification_denied":"You have denied permission for desktop notification for this site","notification_status_delimitor":";","error":"Error","adblock_interferance_message":"Adblock (or similar extension) is known to interfere with SmartVideo. Please add this url to adblock whitelist.","calculating":"Calculating","waiting":"Waiting","will_start_buffering_when_initialized":"Will start buffering when initialized","will_start_playing_when_initialized":"Will start playing when initialized","completed":"Completed","buffering_stalled":"Buffering is stalled. Will stop.","stopped":"Stopped","hr":"Hr","min":"Min","sec":"Sec","any_moment":"Any Moment","popup_donate_to":"Donate to","extension_id":null},"prefs":{"desktopNotification":true,"soundNotification":true,"logLevel":0,"enable":true,"loop":false,"hidePopup":false,"autoPlay":false,"autoBuffer":false,"autoPlayOnBuffer":false,"autoPlayOnBufferPercentage":42,"autoPlayOnSmartBuffer":true,"quality":"default","fshd":false,"onlyNotification":false,"enableFullScreen":true,"saveBandwidth":false,"hideAnnotations":false,"turnOffPagedBuffering":false}}" event="preferencesUpdated" id="myTubeRelayElementToPage"></mytubeelement><mytubeelement data="{"loadBundle":true}" event="relayPrefs" id="myTubeRelayElementToTab"></mytubeelement>

Enable Globbing in PowerShell Active Directory Cmdlet

$
0
0

Hello,

So I am trying to remove a large list of computers from Active Directory, and I only have partial names for each (inventory numbers in the middle of the computer name...)

Is there any way to enable wildcards? So far, I have this for the powershell code I'm using: 

Import-Module ActiveDirectory

$computers = get-content C:\computers.txt | Get-ADComputer -Properties ProtectedFromAccidentalDeletion
$computers | Set-ADObject -ProtectedFromAccidentalDeletion $false
$computers | Remove-ADComputer

I found something online called Globbing, but I'm not sure how to enable it in this case. I'm new to PowerShell and still don't know much.

If anyone could help me out, I'd really appreciate it. Thank you!

Enable Wildcards in PowerShell Active Directory Cmdlet

$
0
0

Hello,

So I am trying to remove a large list of computers from Active Directory in a text file, and I only have partial names for each (inventory numbers in the middle of the computer name...)

Is there any way to enable wildcards? So far, I have this for the powershell code I'm using: 

Import-Module ActiveDirectory

$computers = get-content C:\computers.txt | Get-ADComputer -Properties ProtectedFromAccidentalDeletion
$computers | Set-ADObject -ProtectedFromAccidentalDeletion $false
$computers | Remove-ADComputer

I found something online called Globbing, but I'm not sure how to enable it in this case. I'm new to PowerShell and still don't know much.

If anyone could help me out, I'd really appreciate it. Thank you!


New-Object: Cannot find type [[System.Security.AccessControl.FileSystemAccessRule]]

$
0
0

Hi

I have created a script to create new users and the user is created and well as the their home folder but get the above error when trying to create an ACL for the folder. Below is the part of the script that fails and below that is the error:

$AccessRule=NEW-OBJECT [System.Security.AccessControl.FileSystemAccessRule]($IdentityReference,$FileSystemAccessRights,$InheritanceFlags,$PropogationFlags,$AccessControl);

$HomeFolderACL.AddAccessRule($AccessRule);

#Sets the access rule on the home folder

SET-ACL –path $_.HomeDirectory -AclObject $HomeFolderACL;

}

NEW-OBJECT : Cannot find type
[[System.Security.AccessControl.FileSystemAccessRule]]: make sure the assembly
containing this type is loaded.
At C:\Scriptfinalv1.1.ps1:30 char:13
+ $AccessRule=NEW-OBJECT
[System.Security.AccessControl.FileSystemAccessRule]($Ide ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentExcepti
   on
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewOb
   jectCommand

Exception calling "AddAccessRule" with "1" argument(s): "Value cannot be null.
Parameter name: rule"
At C:\Scriptfinalv1.1.ps1:32 char:1
+ $HomeFolderACL.AddAccessRule($AccessRule);
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException

Any help appreciated

Shane

 

Viewing all 15028 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>