Powershell

15K

Solutions

7K

Contributors

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.

Share tech news, updates, or what's on your mind.

Sign up to Post

Im having trouble setting group membership for NIS in AD via Powershell.

I have a script that creates groups, sets their NIS domain and GID, then adds a list of users to the Windows side of the group Membership, then recurse through those to check that the users ahve a NIS domain, and UID set, if not sets them, and then I want to add the users to Unix side of group membership.

I've found the property I need to set "msSFU30PosixMember", this is the field that populates when I add users via the GUI, but when I populate that field manually (with an array of Distinguished Names), I see nothing in the users list. The weird thing being it recognises that there is "something" there, becasue the remove button is clickable in the GUI, even with nothing highlighted, usually its greyed out.

Anyone done this before and know what im missing, 95% of my script is working but this last bit it now rather winding me up, espeically as the other fields, NIS Domain, GID, UID etc are all working as expected.
0
Ransomware Attacks Keeping You Up at Night?
Ransomware Attacks Keeping You Up at Night?

Will your organization be ransomware's next victim?  The good news is that these attacks are predicable and therefore preventable. Learn more about how you can  stop a ransomware attacks before encryption takes place with our Ransomware Prevention Kit!

Hi All,

Can anyone here please share some tips or steps in Group Policy in how to create the Outlook Email signature for each people in different OU ?

For Example:

Domain.com/Users/Accounting --> Email Signature Template ACC1.
Domain.com/Users/IT --> Email Signature Template IT1.
Domain.com/Users/Marketing --> Email Signature Template MRK1.

How to do that based on each OU ?

Note, the users are using various different OS and Office product like:
Operating System: Windows 7 and Windows 10
MS Office: 2010, 2013 and 2016 (some will use 64 bit, but majority is 32 bit)

Any help and guidance will be greatly appreciated,

Thanks,
0
hi,

I am getting below error message when I am starting exchange powershell on one of my exchange server. Please help on this.

"Connecting to remote server failed with the following error message : The WinRM client cannot pro
cess the request. It cannot determine the content type of the HTTP response from the destination computer. The content
type is absent or invalid. For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [], PSRemotingTransportExc
   eption
    + FullyQualifiedErrorId : PSSessionOpenFailed"


Regards,
Jitendra Gautam
0
I have used the following powershell to generate a list of inactive user. I find that some active users still show out. Is it possiblel to use other attribute to increase the accurancy ?
Thx

Search-ADAccount -UsersOnly -AccountInactive -TimeSpan 60

InactiveUsers
0
This script gets the services on a set of systems, and returns the service name, 'logon as' and server it is on, then exports it to a csv file. This works fine.
I tried adding a where-object to it to remove "local System"  "Network Service" "LocalSystem" any by themselves do nothing, with a -or also does nothing. My attempts have been in vain, is there an easy way to filter out the chaf?
$datetime = (get-date -f yyyy-MM-dd-HH-mm)
Get-Content systems.txt| Foreach-object  {
  Write-Host "Retrieving Servers for $_ "    
  Get-WmiObject win32_service -ComputerName $_  | select Name,
  @{N="Service Account";E={$_.StartName}},
  @{N="System Name";E={$_.Systemname}}}|where-object { $_.StartName -notlike "LocalSystem"} |export-csv -path  D:\path\$datetime-Services.csv -nti

Open in new window

0
Is it possible to inlcude the Office / Location of the AD users account in the following output ?


Search-ADAccount -UsersOnly -AccountInactive -TimeSpan 60 | ?{$_.enabled -eq $True} | Get-ADUser -Properties Name, sAMAccountName | Select Name, sAMAccountName
0
What is the usage of "$" in the following powershell statement ? Thx

$smtpBody = & Search-ADAccount -UsersOnly -AccountInactive -TimeSpan 60 | ?{$_.enabled -eq $True} | Get-ADUser -Properties Name, sAMAccountName, givenName, sn | Select Name, sAMAccountName, givenName, sn | Out-String
0
Need to export users from google g-suite and import into AD DC2016.  Powershell script or other tool?

Anyone done that?
1
I have been trying to rationalize a number of GPOs and have been trying to come up with a Powershell script that will dump the settings "contained" in the GPOs and output them into a CSV or something similar so I can see which settings are duplicated or incorrect - in an easy readable format.

 I figured the easiest way to get this would be to pull the GPO Report to a XML using Get-GPReport -Name $GPO -ReportType XML but am kind of lost on how to parse the XML to get something useful out of it. Any words of wisdom would be greatly appreciated.

Thank you so much.
0
I installed the free downloadable 2016 HyperV, created a VM using Powershell, started the VM, but I can't connect to it with my laptop (win10 pro) running the HyperV Manager. It just doesn't find it when I give either the name of the VM or the IP. I tried installing W2016 at the DOS prompt, but it just did a physical install.

I'm missing some switch or something but the documentation from MS is not very helpful. Thanks in advance for  your help!
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 4
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Hi,

There are some remote W7 machines (different domain) which I need an software inventory of.
Tried to enable remote powershell but it fails on some machines so I better stick to wmi.

Script below works fine, but my output is not yet what I need = Excel with all pc's and their software (pivot table).
The output is now in a ormat which I'd like to convert to:
computer01 software01
computer01 software02
computer01 software03
computer02 software02

So I can export it to Excel then make the pivot table.
My questions: how to continue  + is the WMI query showing all software or should I add extra queries?
Thanks!
---
This is the script so far:

$Workstations| ForEach-Object {
       
       Write-Host "Getting sofware of $_"      
       $Software = Get-WmiObject -Class Win32_Product -ComputerName $_
       $Overview += [PSCustomObject] @{
              Computer = $Software.pscomputername
              Software  =  $Software.caption
            }    
}
 $Overview

Computer                                                                                        Software                                                                                      
--------                                                                                        --------                                                                                      
{Computer01, Computer01, Computer01, Computer01...}                                                         …
0
Hello Experts,


I was assigned with a new task from one of my clients where he is looking to replace an old VB script that maps network drives based on some criteria.


I need to know what option would be the best even if writing a new PowerShell script or work with group preferences in AD.

The current logon script :

Maps several network drives to multiple folders for different departments.

If a machine is part of an OU, then the script will map several network drives

If an user is member of an specific group in AD, and based on sort AD attribute, then the logon script will map specific network drives.

As u can see, there are different conditions to map network drives for users based on their department, the computer machine assigned and some AD attributes.

Based on your experience, what option is feasible? PowerShell logon script or group preference, or something else?
0
I think the title states it all. Can this be done? Using -verbose captures output from SELECT, PRINT and RAISERROR statements to the console but I can't seem to also get them into the transcript file within a PowerShell script.
I know I can capture the output from SELECT statements into a variable, but that does not help with RAISERROR or PRINT statements.
0
looking for a powershell script to check the following

- check all accounts locked in last 60 minutes (not lockout state, but the actual lockout event)

items needed... name, upn, lockout source, domain controller, last badpassword, badpassword attempts
0
Currently, my script has code similar to:
$ServerDatabasePairs = @"
Server,Database
server1,database1
server1,database2
server2,database3
"@ | convertFrom-CSV

Open in new window

I am wanting to process data from a configuration file. This file is in a key,value format. I want to have a key named ServerDatabasePairs that has a value something like:
ServerDatabasePairs,"server1|database1,server1|database2,server2|database3"

Open in new window

and ultimately parse it the same as the existing code above (e.g. into a two-dimensional table).
Not sure how to accomplish this.
0
this EOP interface is not making me a happy camper but maybe is a good op to improve my powershell.
I have a need to extract a quarantine report on a daily basis. the current request is to have a COMPLETE dump on a scheduled basisi. I have the basics down but it looks like I only get a max of 1000 entries at a time and any page but I need to know how many pages.
is there a way around this? I'm working on the possibility of a day bracketed report but it still may be more than 1 page.
do I just have a page 1 page 2 page 3 report??

any help appreciated
0
Hi,
  I am trying to install KB2922223 on a machine which has Windows Embedded Standard OS version 7.
  When I am installing it is saying the update KB2922223 is already available on this computer. But when i see
  in the installed patches, I could not see it listed there.  And when I use the powershell script get-hotfix also it is not showing as installed. So basically though it is not installed it is treating as installed and not going ahead with installation. Anyone come across this scenario?

Thanks,
Ashok
0
Hi,

I have this sharepoint link:
http://ourserver.ourdomain.com/Asset%20database/Servers.aspx on which there is an entry for each server.
F.e.
Hostname  Function
Server01  Exchange server
Server02  Database
Etc

Each hostname is a link which gives full details when you click on it.
Now I would like to be able to look for Server01 via Powershell and show the output in a webbrowser.
Tried via
$webclient = New-Object system.net.webclient
$content = $webclient.DownloadString("http://ourserver.ourdomain.com/Asset%20database/Servers.aspx")
Idea was then to find the link in the $content then make Powershell look for link and show it, but get an access denied on the downloadstring.

Please advise howto achieve this.
J.
0
Can you please help me in deleting the Key named "Certificates" located in the following path using PowerShell Script.

"HKEY_LOCAL_MACHINE\Software\Microsoft\SystemCertificates\SMS"

 Registry
We are using Windows Server 2012 R2
0
NFR key for Veeam Backup for Microsoft Office 365
LVL 1
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Hi Guys.

I'm writing a small script to get the Message count of a specific Queue.

Get-Queue -Server cas1 -Filter {DeliveryType -eq "SmartHost"} |fl MessageCount

Open in new window


The result is

MessageCount : 0

How an I modify this line to only return the actual number (without the parameter name and / or any spaces)
0
Hi all,

I have a Powershell script that copies AD group memberships from one user account to another. The script is as follows:

 
Import-Module ActiveDirectory

$copy = Read-host "Enter user to copy from"
$Sam  = Read-host "Enter user to copy to"
 Function Copymembership {

$members = Get-ADUser -Identity $copy -Properties memberof
foreach ($groups in $members.memberof){
if ($members -notcontains $groups.sAMAccountname)
{Add-ADGroupMember -Identity $groups -Member $sam -ErrorAction SilentlyContinue
Write-Output $groups} 
}
}
copymembership

Open in new window



Running the script prompts for both the source account and the target account to be entered, before going off and 'doing the do'.

I now have the requirement to copy AD account memberships for hundreds of users. I have a CSV with the data, an example of the formatting is below...

SourceUser, TargetUser
TestUser1,TestUser1NEW
TestUser2,TestUser2NEW  


I have been trying to find a way to import the CSV into the original script above, and go through the list copying memberships from each source user to their target account.

Any pointers/help/advice would be greatly appreciated.

Cheers
0
Hi,
I am trying to call a powercli script to Expand the harddisk in a VM with invoke-command , the same script is working fine in powershell host mannually, but when calling from vRO, its showing that workflow is successful with green tick but nothing reflected in VM(Windows 2012 R2). Can anyone tell if there is alternate to do the same.
0
Hi All,

I'm running Exchange server 2013 standard edition, and I tried to remove some of the old AD account from accessing the shared mailbox, using the PowerShell command:
Get the SID: Get-ADUser -Identity Kacung.Semprul
Remove the user: Remove-MailboxPermission -Identity Shared-MBX-1 -User "S-1-5-21-3684462478-1056977450-1152882164-8921" -AccessRights FullAccess -InheritanceType All -Deny:$true

But somehow I can not go through due to this error:
can't remove the access control entry on the object because the ace doesn't exist on the object

I've tried:
https://social.technet.microsoft.com/wiki/contents/articles/31321.exchange-serveronline-the-ace-doesn-t-exist-on-the-object.aspx
http://clintboessen.blogspot.com.au/2015/04/unable-to-remove-mailbox-permission-in.html

But still not working for me.
0
Hi All,

Greetings...

According to my work, I need to zip files present in a folder using batch script without using any 3rd party software.

I tried with below code ,but getting the error.error also attached below.

Any help regarding this would be highly appreciated.
'Get command-line arguments.
Set objArgs = WScript.Arguments
Set FS = CreateObject("Scripting.FileSystemObject")
InputFolder = FS.GetAbsolutePathName(objArgs(0))
ZipFile = FS.GetAbsolutePathName(objArgs(1))

'Create empty ZIP file.
CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" & Chr(5) & Chr(6) & String(18, vbNullChar)

Set objShell = CreateObject("Shell.Application")

Set source = objShell.NameSpace(InputFolder).Items

objShell.NameSpace(ZipFile).CopyHere(source)

'Required!
wScript.Sleep 2000

Open in new window


This code is present in zip.vbs file. We have to zip the files into Outputfile.zip file.
in command prompt  , I have entered below command

C:\Users\abc>Cscript zip.vbs input path  output path\OutputFile.zip

While executing this ,I got below error. " Path not found error" for both the input and output file path.

It will be helpful if anyone corrects me the mistake which I made in this script.
2
When importing users to AD using Powershell, got an error message
New-ADUser : A value for the attribute was not in the acceptable range of values



New-ADUser : A value for the attribute was not in the acceptable range of values
At line:4 char:5
+     New-ADUser -Name $temp_user.Name `
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (CN=Ray Johnson,...C=renevo,DC=int:String) [New-ADUser], ADException
    + FullyQualifiedErrorId : A value for the attribute was not in the acceptable range of values,Microsoft.ActiveDirectory.Management.Commands.NewADUser
 
New-ADUser : A value for the attribute was not in the acceptable range of values
At line:4 char:5
+     New-ADUser -Name $temp_user.Name `
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (CN=Scott Harris...C=renevo,DC=int:String) [New-ADUser], ADException
    + FullyQualifiedErrorId : A value for the attribute was not in the acceptable range of values,Microsoft.ActiveDirectory.Management.Commands.NewADUser




here is the script.

$temp_users=Import-Csv -Path Z:\C\Temp\test_users.csv
foreach($temp_user in $temp_users)
{
    New-ADUser -Name $temp_user.Name `
        -DisplayName $temp_user.DisplayName `
        -GivenName $temp_user.GivenName `
        -Initials $temp_user.Initials `
        -Surname $temp_user.Surname `
        -EmployeeID $temp_user.EmployeeID `
        -EmployeeNumber $temp_user.EmployeeNumber `
   …
0

Powershell

15K

Solutions

7K

Contributors

Windows PowerShell is a task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET Framework. PowerShell provides full access to the Component Object Model (COM) and Windows Management Instrumentation (WMI), enabling administrators to perform administrative tasks on both local and remote Windows systems as well as WS-Management and Common Information Model (CIM) enabling management of remote Linux systems and network devices.