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

Hello,
I am getting below error after I patched Win208 R2 servers.  

attempting to perform the initializedefaultdrives operation on the "filesystem" provider failed

I did removed the patches which were installed but it still gives the error.  Unable to figure out what specific patch initiated issue.  Do anyone knows this error and any hotfix for the same released by MS?
In need to get a fix for this issue on priority.
0
NFR key for Veeam Agent for Linux
LVL 1
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

$Path = "$env:USERPROFILE\appdata\roaming\"

$Files="*.pdf","*.doc","*.dot","*.docx","*.docm","*.dotx","*.dotm","*.docb","*.xls","*.xlt","*.xlm","*.xltx","*.xlsm","*.xlsb","*.xla","*.pptx","*.pptm","*.potx","*.potm","*.ppsx","*.ppsm"

Get-childitem $Path -include $Files -recurse | foreach ($_) {remove-item $_.fullname}

Open in new window



Ok,

So this is meant to delete all files associated with the above file types, it doesn't. It also doesn't pull the array correctly, it only pulls *.PDF

I'm getting rather frustrated. Could someone help again please :(
0
Good morning all,

OK so

There is a process our machines follow when they boot up, I need to remove an array of file types, thus I have the following script
$Files ='*.pdf','*.doc','*.dot','*.docx','*.docm','*.dotx','*.dotm','*.docb','*.xls','*.xlt','*.xlm','*.xltx','*.xlsm','*.xlsb','*.xla','*.pptx','*.pptm','*.potx','*.potm','*.ppsx','*.ppsm'

Remove-Item "c:\users\$env:UserName\appdata\roaming\Noname"


Get-ChildItem -Path 'c:\users\$env:UserName\appdata\roaming\Noname' $Files | foreach { Remove-Item -Path $_.FullName }

Open in new window


Doesn't work, nor can any amount of googling help :(

Could someone give me a hit in the right direction?

Thank you very much

Alex
0
Trying to get a simple list of samacvountnsme

New-item command that writes to log. And also want a friendly message to screen

New-item.......

Else
{write-host ("Folder created for " + $ADUSER.samaccount)}


I get

Mode.       Lastwritetime.    Length.  Name.  


Just want the name column

{write-host ("Folder created for " + $ADUSER.samaccount) | format table name}. Doesn't do anything
0
trying to prepare a form which can be reused for any project to re-validate the credential with one-time-saved credentials...

it should save the credentials locally and next time when same user try to login the credentials it should auto use the locally stored/cached credentials...

don't know where it is going wrong but really appreciate if you could help me fixing it.

Cheers
Aamer
Save-Creds.txt
0
I am working on a powershell script to take this command.

Get-WmiObject -Class Win32Reg_AddRemovePrograms | Select-String -Pattern "exchange"

and if it equals this:

\\A01344\root\cimv2:Win32Reg_AddRemovePrograms.ProdID="Microsoft Exchange v14"

Then do nothing.

But if it does not equal that then run a reg file.

I am new at this please assist. Thank you in advance.
0
I have a website running on server 2012 using IIS. I want a contact page to send emails to a distribution group. It is all internal, we have an smtp relay server. As I have searched around to find examples I keep finding commercial stuff. I am hoping to be able to use powershell to send the email. I currently am using mailto, so it uses the users default email client, filling in to and subject and body. I would much rather have it send from the server, and not use the client. Can anyone point me at an example?
0
I have been using this power shell command to create a text files that lists the currently installed programs on Windows 10 computers:

Get-WmiObject -Class Win32_Product | Select-Object -Property Name > C:\PCapps.txt

Open in new window


The problem is that this command lists only the names of the installed programs.

I would like to run a command that will display the complete list of everything that is displayed within the Programs and Features applet: Software name, publisher, installed on, size, & version.

What is the correct syntax of a command that will display all this information?
0
I am running some queries in Powershell.

I have created a function that returns an object I can use foreach (hence the return ,$table)
I first obtain a sql reader and load a data table with the returned recordset.

$rdr = $command.ExecuteReader()
          
 $table = new-object “System.Data.DataTable”
 $table.Load($rdr )
    
  return ,$table

Open in new window


The issue is that when iterating through the results I cannot perform an additional calls $command.ExecuteReader() even if I create a new command object and set the query text for that new command object.

I get the following error when I try: "There is already an open DataReader associated with this Command which must be closed first."

So I tried to close the reader after loading the data table

$rdr = $command.ExecuteReader()
          
 $table = new-object “System.Data.DataTable”
 $table.Load($rdr)
 $rdr.Close()

  return ,$table

Open in new window


With the data table filled and returned by the function, why can't I close the reader and then make a subsquent call to $command.ExecuteReader() ????
0
is it possible to get corresponding email attribute from object property of user
0
Is Your AD Toolbox Looking More Like a Toybox?
LVL 6
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

I'm trying to open two PowerPoint files from powershell and sync then together. Then I have to create a loop that checks to see if there has been an update to the files every hour and if so it will update them.

So far I have assigned the source file and prompted the user to enter the file path, and then used Invoke-Item to open it; however it only opens up to display the files and not automatically open them. Any advice would be appreciated.
0
I am working on a project where we need to identify Shared Mailboxes that are still in use. We run Outlook 2010 and Exchange 2013. I don't know whether Mailbox auditing is on or off, I would assume its currently off as per the default

There are a large number of these Shared Mailboxes so becoming a member of the group and adding it into Outlook as a new mailbox is not going to be an easy task

We have limited tools available to us and no budget available to buy any at the moment.

The options for tools is currently:

We can run Powershell scripts and we could install the Exchange cmdlets
We might be able to download free software
0
I'm working with multiple remote computers and here is what I found on a previous post and have modified but still not working hope I could get some assistance.

function Get-ServerInfo {
PROCESS {
$image1 = "1234"
$image2 = "5678"
$computername = $_
$os = Get-WMIObject -Class Win32_operatingsystem
$system = Get-WMIObject -Class Win32_ComputerSystem
New-Object PSObject -Property @{
  ComputerName = $computername
  OS = $os.buildnumber

}
}}
Get-Content c:\servers.txt | Get-ServerInfo | Format-Table -auto | export-csv c:\scripts\imagever.csv -notype

2 issues I have
1. script only gets the first wmi query of the buildnumber from the local machine, and then provides the computernames from the list
2. the variables I've declared at the top for the $image1 and $image2 I would like to put into this script once I can get it working properly to perform and if/else statement but to replace the information if it meets a specific criteria and everything I have tried thus far doesn't work

if($os.buildnumber -eq $image1) ){replace that information with 1.0}
if($os.buildnumber -eq $image2){replace that information with 2.0}
else{write-output c:\scripts\image}
0
How would I convert the CSV from this line of code to an HTML file? Inside of Powershell.

Invoke-SelfSearch -ExchHostname outlook.office365.com -Mailbox user@domain.onmicrosoft.com -Remote -OutputCsv archive.csv -Terms *

Thanks!
0
So, apparently Microsoft has pushed out an option on Office 365 e-mail that allows people to give a thumbs up or "like" e-mails people have sent. So far, I haven't found anyway to turn this feature off. All of the articles I've read are people asking how to turn it off but no one has an option yet, even through powershell. Is this an unkillable feature?

Here is what I'm referring to if you don't know: https://support.office.com/en-us/article/Like-an-email-message-in-Outlook-on-the-web-for-business-cfd919a9-7c3e-40ed-a6e6-aabd7d2d2acb?ui=en-US&rs=en-US&ad=US
0
HI All,

I have this powershell script and I need find a secure way of storing the password. I've tried :

$response = Read-host "What's your password?" -AsSecureString 
$Password = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($response)

Open in new window


and this will not work.

below is my script, how do I load the assembly, it prompts and error saying :

Unable to find type [Microsoft.VisualBasic.Interaction]. Make sure that the assembly that contains this type is loaded.
At line:1 char:1

this is the code
#Specifiy Local admin account name
$user = "mcadmin"
  
Add-Type -Assembly System.Web
$pass=[Web.Security.Membership]::GeneratePassword(20,0)
NET USER $user "$pass" /ADD /y
#Add user to local admin group
NET LOCALGROUP "Administrators" "$user" /add
#set password to never expire
WMIC USERACCOUNT WHERE "Name='$user'" SET PasswordExpires=FALSE
  
Write-Host "Username: $user" -foregroundcolor green -backgroundcolor black
Write-Host "Password: $pass" -foregroundcolor green -backgroundcolor black
Write-host "Server: $env:computername" -foregroundcolor green -backgroundcolor black

# Load the classes from KeePass.exe:
cd "\\smile01\Infrastructure\KeePass-2.34" | out-null
(Get-ChildItem -recurse $script:myinvocation.mycommand.path | Where-Object {($_.Extension -EQ ".dll") -or ($_.Extension -eq ".exe")} | ForEach-Object { $AssemblyName=$_.FullName; Try {[Reflection.Assembly]::LoadFile($AssemblyName) } 

Open in new window

0
It sounds like tasks archive based on the received date, not completely sure though.  How can I stop tasks from archiving.  Possibly I could update the received date on all the tasks, although I don't have a way to do that either. Maybe with powershell?
0
Hey

Looking for a powershell script to delete items in recycle bin and download older than 14 days.

(to be used in logoff script)

Thanks in advance

Micke
0
Hello Team,

how can we forward user calles from his skype number to another number through powershell

Please suggest

Thanks,
Addy
0
[Live Webinar] The Cloud Skills Gap
LVL 4
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

GPO Monitor
In the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed or changed with an option for email notifications.
0
Hi Experts,

I have this script tested and works as expected.  script checks the disks attached to server and checks the  drive label  of the disks and create a .txt file with the drive letter name ( such as "D drive.txt")  scripts is copied to  each server already and locally run.

For an example, if four disk found as D, E,Y,S on a local server, after running the script,  when I  go into each disk, I should have a .txt file saved in there as D drive.txt, E drive.txt , Y drive.txt and S drive.txt

batch script will be used on  mixture Windows OS versions. ( 2003 to 2012)

Issue: it works fine when script is run locally but when needed to run using PSexec, it produces different issues  even though script is on the local server and all PSexec should do is executing the script with remotely instead of logging into the each server. I have read on forums that vmic is not very friendly with PSExec, is there way to eliminate wmic from the script? here is forum talks about the issues it causes:  https://forum.sysinternals.com/psexec-hangs-when-running-wmicexe_topic14752.html

thanks in Advance
markerfile.txt
0
How to send commands to the remote server connected using Mstsc...

I am aware of doing this using Devolutions Remote Desktop Manager and other third party tools but looking for a way to achieve this using windows native tools like PowerShell or any other scripting... I could manage to prepare a tool using PowerShell and windows forms but stuck at logon banner screen where as i am unable to send any commands to the remote server over RDP connection..

any ideas/suggestions ?
0
I need help in creating a windows powershell for win server 2008 and 2012 R2 to check the following:

When i run the powershell on the server, it will return if this server is running:
 - Cluster Service or
 - Failover Clustering service enabled/ configured or
 - has any registry keys to indicate that it is part of a cluster
0
I need to search all mailboxes for mail containing 1 of 2 phrases.

My environment:

Hybrid exchange / Office 365 setup.
I need to search from January 1, 2015 - present,
I do NOT need to search student accounts. (student accounts have a "." in their name. "first.last@school.org" Staff have "FirstInitialLastName@school.org")

I attempted to run this search on premise using ECP Multi-Mailbox Search. It failed because the estimated size of the search was 173.2 GB when the discoverysearchmailbox only has 49.48 GB space.
Attempts at running this in the cloud using in-place eDiscovery & hold fail because the search includes too many mailboxes.

I suspect there is a powershell solution for this,  but am open to any other options as well.

Bartender_1
0
Hi All, I had this same question (Listing the Shared Network drive size (UNC path) using powershell) and the solution provided worked perfectly. My problem is the sizes are outputting as things like 4.74842E+1, etc. How do I get them converted o GBs and MBs in the output?
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.