Quantcast
Channel: Windows PowerShell forum
Viewing all 21975 articles
Browse latest View live

New-ADComputer : A required attribute is missing - Issue using "-path"

$
0
0

I am trying to make a simple script to create a new computer object in AD.  I took out all variables and put the real data in and i get an error.  Below is the line of code I am trying to run.  Under that is the error.  Can somebody help me out?

CODE:

 New-ADComputer -Name XXXXXXXX -Description test -Path "OU=Laptop,OU=Computers,OU=SID,OU=US,OU=NA,OU=XXXXX,DC=XXX,DC=ad,DC=XXXXXX,DC=com" -SAMAccountName XXXXXXXX

ERROR:

New-ADComputer : A required attribute is missing
At line:1 char:1
+ New-ADComputer -Name XXXXXXXX -Description test -Path
"OU=Laptop,OU=Computers,OU ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
    + CategoryInfo          : NotSpecified: (CN=XXXXXXXX,OU=...,DC=XXXX,DC=com
   :String) [New-ADComputer], ADException
    + FullyQualifiedErrorId : A required attribute is missing,Microsoft.Active
   Directory.Management.Commands.NewADComputer



How do I use Get-Aduser's Filter to exclude a large number of Import-CSV user accounts ?

$
0
0

Hi,

A few questions here:

1. How do I build a dynamic list of users to use in the Get-Aduser -Filter from the

$ExcludedUsers = Import-Csv $Path? I'd like to 'exclude' these users from processing

during the Get-User operation. Could have 2000-3000 users to exclude at any one time.

2. Is there any limit as to how many I can Filter at any one time?

3. Will the ISE Debugger still work given a large Filter statement?

#Exclude $ExcludeOU1 = "*OU=Mailboxes,DC=MyDomain,DC=Local*" $ExcludeOU2 = "*OU=Accounts,DC=MyDomain,DC=Local*" $ExcludeOU3 = "*OU=USA,DC=MyDomain,DC=Local*" $ExcludeOU4 = "*OU=OS,DC=MyDomain,DC=Local*" $ExcludeOU5 = "*OU=C,DC=MyDomain,DC=Local*" $ExcludeOU6 = "*OU=o,DC=MyDomain,DC=Local*" $ExcludeOU7 = "*OU=n,DC=MyDomain,DC=Local*" $ExcludeOU8 = "*OU=t,DC=MyDomain,DC=Local*" $OU = "DC=MyDomain,DC=Local" # Import Excluded Users $Path = "C:\Users\Fred\ExcludedTest.Csv" $ExcludedUsers = Import-CSV $Path $AllUsers = Get-Aduser -Filter $ExcludedUsers -Properties mail -SearchBase $OU -SearchScope Subtree | ? {$_.DistinguishedName -notlike $ExcludeOU1 -and ` $_.DistinguishedName -notlike $ExcludeOU2 -and ` $_.DistinguishedName -notlike $ExcludeOU3 -and ` $_.DistinguishedName -notlike $ExcludeOU4 -and ` $_.DistinguishedName -notlike $ExcludeOU5 -and ` $_.DistinguishedName -notlike $ExcludeOU6 -and ` $_.DistinguishedName -notlike $ExcludeOU7 -and ` $_.DistinguishedName -notlike $ExcludeOU8 -and ` $_.mail -ne $null}



Thanks for your help! SdeDot

Set-ADUser : Cannot validate argument on parameter 'Replace'. The argument is null

$
0
0

I have a script and im getting the error above.

$path = "c:\temp\******.csv"
$csv = Import-Csv $path
Import-Module ActiveDirectory

foreach($line in $csv){

    $replace = @{}
    If ($line.internTelefoonnummer) { $replace.Add('ipPhone',$line.internTelefoonnummer)}
    If ($line.mobieleTelefoonnummer) { $replace.Add('mobile',$line.mobieleTelefoonnummer)}

 Get-ADUser -LDAPFilter "(&(objectclass=user)(mail=$($line.emailAdres)))" |
    Set-ADUser -OfficePhone $line.internTelefoonnummer -Replace $replace
}

Full error:

Set-ADUser : Cannot validate argument on parameter 'Replace'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a colle

ction that does not contain any null values and then try the command again.

Can anyone help me out and tell me what is wrong with my script.

PowerShell program installer (need help new to powershell)

$
0
0

this is my older code but what i'm trying to do is run this from a non-domain computer to a domain sever thats sharing the file now matter what way i do it i can't get them running off the server but locally i can its odd . any help would be very nice . thanks

Write-Output `-----------------------------------------------------------------`
Write-Output `Auto Installer`
Write-Output ``
Write-Output `By: Douglas Gray`
Write-Output `----------------------------------------------------------------`

Write-Output `starting Setup`


start-process setup.exe -ArgumentList /sAll -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
Write-Output `Adobe Reader finish`

start-process adobeair.exe -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
Write-Output `Adobe air finish`

start-process vpnclient_setup.msi -ArgumentList /quiet -workingdirectory "\\kws-\sofware & drivers\kwsit\vpnclient64\" -wait
Write-Output `cisco vpn finish`

start-process Communicator.msi -ArgumentList /queit -workingdirectory "\\kws-\sofware & drivers\kwsit\Communicator\" -wait
Write-Output `communitcator finish`

start-process flashff.exe -ArgumentList /install -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
Write-Output `Adobe flash OB finish`

start-process flashie.exe -ArgumentList /install -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
Write-Output `Adobe flash IE finish`

start-process javai586.exe -ArgumentList /s -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
Write-Output `java 32bit finish`

start-process Meraki.msi -ArgumentList /quiet -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
Write-Output `meraki finish`

copy-item "\\kws-\sofware & drivers\kwsit\Desktop" "\\kws-\sofware & drivers\users\public\desktop" -force -recurse -verbose
Write-Output `Desktop moved`

start-process winrar.exe -ArgumentList /s -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
Write-Output `winrar finish`


start-process javai58664.exe -ArgumentList /s -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
Write-Output `java finish`

start-process Silverlight64.exe -ArgumentList /Q -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
Write-Output `java finish`

start-process AppleApplicationSupport.msi -ArgumentList /qn -workingdirectory "\\kws-\software & drivers\kwsit\iTunes64\" -wait
start-process AppleMobileDeviceSupport64.msi -ArgumentList /qn -workingdirectory "\\kws-\software & drivers\kwsit\iTunes64\" -wait
start-process AppleSoftwareUpdate.msi -ArgumentList /qn -workingdirectory "\\kws-\software & drivers\kwsit\iTunes64\" -wait
start-process Bonjour64.msi -ArgumentList /qn -workingdirectory "\\kws-\software & drivers\kwsit\iTunes64\" -wait
start-process iTunes64.msi -ArgumentList /qn -workingdirectory "\\kws-\software & drivers\kwsit\iTunes64\" -wait
Write-Output `itunes finish`

start-process setup.exe -ArgumentList $office -workingdirectory "\\kws-\sofware & drivers\kwsit\office13\" -wait
Write-Output `office finish`
$office = "\\kws-\sofware & drivers\kwsit\office13\proplus.WW\config.xml"

start-process LogMeIn.msi -ArgumentList /quiet -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
Write-Output `logmein finish`

start-process googleearth.exe  -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
Write-Output `google earth finish`

start-process mcafee.exe  -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
start-process sasetup.exe  -workingdirectory "\\kws-\software & drivers\kwsit\" -wait
Write-Output `mcafee finish`

Can some one help me

$
0
0

Hi All,

am running a powershell command to get the disk space for remote computer in other subnet an which is a trusted domain system.

while running the power shell command getting error get-wmiobject rpc server unavailable. but am am able to query the WMI and connect the remote system wmi through wbemtest. Can some one help me in this. 

typewriter text in powershell?

$
0
0

I've just started out with powershell, is there a way to make text have a typewriter effect, as if someone is writing it?

I understand that Write-Host ouputs the text, and I can use Start-Sleep for delays between chunks of text, but I need to have delays between each character of a word.

accept default "y"

$
0
0

stop the prompt from asking yes or no when using the PS below?

Import-CSV .\file.csv | %{ Disable-UMMailbox -Identity $_.Identity -KeepProperties:$False}

How to determine location of a VHD image using using its mounted drive letter?

$
0
0

Hi,

I have a VHD boot based on Window 8.1 Enterprise, starting my laptop in a live manner from a USB drive. The problem is to find out a way to determine theexact location of this VHD image; that is, the drive letter of the USB disk drive containing that image.

Another question is that when I list the disks in the powershell environment, I need to know which of the disks are actuallymounted Virtual Hard Disks. Powershell normally shows them as fixed disks.

Thanks


Windows powershell script to identify members, removed from active directory group

$
0
0

hi,

I deleted some users from an active directory group before 4  5 days, by mistake.

Is there any powershell script that can return past members of an active directory group ?

any clue ?

thanks in advance.

Powershell hangs if Get-VM is used

$
0
0

Fairly straight forward. Powershell hangs (5days +)

Server is 6.2.9200 "Hyper-V Server 2012"

Equivalent setup to several other servers - all without issue

C:\temp>powershell
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.

PS C:\temp> $pop = get-vm
PS C:\temp> exit

Ctrl-Break typed; exiting.

Update: Wait chain says powershell is waiting for another process(svchost.exe)

The svhost inquestion seems to be netsvcs - hosting Window Management Instrumentation

getting information from another computer and putting it in a dir on server where I am running command from

$
0
0

I am trying to get this command to work

gsv -ComputerName vm-de1f-fdc4 | out-file d:\p2p/vm-de1f-fdc4.txt

I get

get-services : cannot open services control manager on computer vm-de1f-fdc4 this operation might require other privileges

Powershell to get-acls get-acl id from database table and insert ID on another table

$
0
0

Hello all,

Here iam again. Would like some help on How can i implement the following:

I have a few shares on the network. I ll get all the folder and file permissions with get-acl and get that info to a dabatase table. Problem is that i dont wanna to pu the full descriptor (ex: ReadandExecute). Because of that i ll have on the same database a table called perms. There i ll associate one Id to a permission.

Here comes my question. Which permissions should i put on this perms table? I only want access permissions. But i need to be sure that when i get one permission from a folder it already exists on the perms table.

Anyone able to help with this?

Regards,


Arestas

get-acl : Cannot find path '\\fileshare\test\Share\' because it does not exist

$
0
0

Hello all, 

Iam getting the following error when i use $acc=(get-acl $file).Access

$file is a obtained from a database with the following query:

foreach ($file in Invoke-Sqlcmd -Query "select FO_ID,FULL_PATH from dbo.$T_FOLDERS" -ServerInstance "xxx\xxx" -Database "xxx"  |select -ExpandProperty FULL_PATH)


 ERROR:

get-acl : Cannot find path '\\fileshare\test\Share\' because it does not exist.
At line:17 char:11
+     $acc=(get-acl $file).Access
+           ~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (:) [Get-Acl], ItemNotFoundException
    + FullyQualifiedErrorId : GetAcl_PathNotFound_Exception,Microsoft.PowerShell.Commands.GetAclCommand

Can anyone help me with this one?

Regards,

Arestas

How to know if $variable is User or group

$
0
0

Hello all,

I could use some help finding the best way to know if some "name" saved in a some variable its a AD User or a AD group.

Any ideas on how to find it?

Regards,

Arestas

issue Invoke-Webrequest with a proxy server

$
0
0

the following commands work only after a connection with a webbrowser. It does also not work with "Get-Credentials" for the proxycredentials. However, if a one-time connection to a browser have been set up, no password is required (it works without  "-ProxyCredential $myCreds")

Has anyone an idea? why the Proxy authentication does not work with powershell (3.0)?

$proxy = 'http://192.168.178.14:8080'
$proxyuser = 'proxyuser'
$proxypassword = 'system'
 
$secPasswd = ConvertTo-SecureString $proxypassword -AsPlainText -Force
$myCreds = New-Object System.Management.Automation.PSCredential -ArgumentList $proxyuser, $secPasswd
$Test = Invoke-WebRequest -URI 'http://www.software-virtualisierung.de' -Proxy $proxy -ProxyCredential $myCreds
$Test.Links
 

Windows 10 PowerShel/Internet Explorer Automation Problem

$
0
0

Hello,

I have a PowerShell script that I use to automate an Internet Explorer window. Basically the code does this:

$ie = New-Object -com InternetExplorer.Application

$ie.navigate('https://www.somewebsite.aspx')

Start-Sleep -Seconds 60  # My code checks for Busy and ReadyState, but this will suffice

$someField = $ie.document.getElementById('theNameOfTheField')

if ($someField -eq $null)
{
     Write-Output 'Some field was not found'
}

I'm passing the name of the field and not the ID. In Windows 7 this works just fine and the field is found. In Window 10, the field is not found.

According to the online documentation (https://msdn.microsoft.com/en-us/library/ms536437%28v=vs.85%29.aspx), the getElementById field will match on the ID or NAME attribute.

In Windows 10 this is not happening. If I use the ID, the element is found with no problems.

The other problem is that Windows 10 doesn't return a null when it fails (as the documentation states it should). It returns an object of the type System.DBNull.

Thanks,

Steve :)





Get Partner agents with full access and limited access users in office365 using powershell

$
0
0

Hi,

how to retrieve the "Partner agents with full access" and "Partner agents with limited access" users in office365 using powershell?

Thanks

Venkat

how to retrieve the "Partner agents with full access" and "Partner agents with limited access" users in office365 using powershell?

$
0
0

how to retrieve the "Partner agents with full access" and "Partner agents with limited access" users in office365 using powershell?

thanks

venkat

Powershell script to check single regestry value in every pc on Subnet or OU

$
0
0

I need to produce a list of all PC in a given subnet where registry value of a pc isnot equal to  abc.eu.company.com

the command below can check registry on a single pc.

Import-Module PSRemoteRegistry
Get-RegValue -ComputerName $PC -key "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" -value Domain

I would like to run it across 3 different subsets, or a specified OU.

and return a list of PC where that value is not abc.eu.company.com.

I'm new to powershell and if anyone can point me in the right direction or provide an example it would be great.

Warning: 'EnableWriteOrderPreservationAcrossDisks' is not required for 'Set-VMReplication'.

$
0
0

When we run set-vmreplication -vmname **** -EnableWriteOrderPreservationAcrossDisks 1we get WARNING: 'EnableWriteOrderPreservationAcrossDisks' is not required for 'Set-VMReplication'.

I can see other threads asking the exact same question I'd be about to - so is it even enabled? There's no confirmation. Checking the Technet for "Get-VMReplication" doesn't give anything obvious how to check.

As obscure as this command to enable the write order preservation is, so is the command to check which requires piping and advanced knowledge of Powershell, and no where I can find documentation how to find this info how to check.

Get-vmreplication -VMname ****** | fl enab* shows True for the server we've just ran the command on. Great.

But then curious I ran the command on each server we have utilising Replica. Result? It shows all servers as having this enabled. I've googled and looked into this and as far as I can possibly tell the default for Write Order Preservation is disabled and you are required to enable it - reading the Technet article explaining SQL support clearly says you need to enable the featurelink here.

So what's the go? Is it enabled for our one server we specified? Is it enabled for all? Is the command Get-VMReplication indeed showing the correct information?

And then some bigger questions - Why is this not in the GUI? It's clearly a very important thing to have and be made clear about it's presence.

Why is it so poorly documented the use of this feature? Even where mentioned to "enable" it say in the SQL blog it gives no information if you are meant to enable it from any PC, the Hyper V host, the SQL guest etc.

What frustrates me most is no one from Microsoft will do anything with these really important questions and there'll be no clear answer to this headache of what is an essential thing apparently.

Viewing all 21975 articles
Browse latest View live


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