Go Premium for a chance to win a PS4. Enter to Win

x

Powershell

16K

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 All,

I have been given access to two subscription which are of two separate projects. When I run the command Get-AzurePublishSettingsFile using powershell it show me one one subscription, and when I use Get-AzureRmSubscription it shows me the other one.

Now I want the 2nd one which needs be made as default and when I download the file it should show me all or the one which I want to use henceforth as default.

For Subscription A I have access as Owner and for B I have as contractor. I need to be using Subscription B from now on. All commands and management or admin commands should be executed on Subscription B.

Also, I wanted to know what is the difference B/W these 2 commands: Get-AzureRmSubscription & Get-AzureSubscription

Any help or assistance is appreciable.

Please let me know if you require anymore info.
0
[Webinar] Cloud and Mobile-First Strategy
LVL 11
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

I am trying to audit the permissions on a file server as a domain administrator and am getting an error for 'unauthorized operation' on some uses. When I use D:\Share\IT, I am able to get the command to run; when I use \Prod I cannot.

I am using the following in PowerShell:
Get-ChildItem D:\Share\Prod -Directory -Recurse | Get-Acl | Select-Object path,accesstostring,owner| Export-Csv C:\Temp\file.csv

I am receiving the following error:
Get-Acl : Attempted to perform an unauthorized operation.
At line:1 char:51
+ Get-ChildItem D:\Share\Prod -Directory -Recurse | Get-Acl |Select-Object  ...
    + CategoryInfo          : NotSpecified: (:) [Get-Acl], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.GetAclCommand

I am logged in as a domain administrator, with PowerShell using Run As Administrator.
0
Thanks to Rick_2CA - https://gallery.technet.microsoft.com/office/Mailbox-Pre-Archive-347f9162/view/Discussions

I have been able to Modify this script to include: TotalDeleteditemSize and TotalDeleteditemCount

This outputs the below and works exactly how I want:

ItemsCount      
ArchiveItemsCount      
ItemsSizeBytes      
ArchiveItemsSizeBytes      
TotalDeletedItemSize            
DeletedItemCount


The part I am having trouble with, and where I would like a push in the right direction is how to obtain the ArchiveTotalDeleteditemSize & ArchiveTotalDeleteditemCount (The count and size of data that CAN be archived, same as what is output from "ArchiveItemsSizeBytes")

Below is the script, that I have manipulated to include the

TotalDeleteditemSize & TotalDeleteditemCount......

I have attempted to match what was already in the script, by copying the code, and changing the values (Via Powershell ISE), However, I just end up with nothing being returned or getting the identical results as the ArchiveItemsizebytes

Essentially I am after the Archivable size & Count for recoverable deleted items

Any assistance would be greatly appreciated!!!

If I have worded anything wrongly, or something does not make sense, please let me know, and I will be happy to clarify...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


# Exchange 2010 Mailbox PreArchive Statistics
# Purpose:  Query mailboxes for mail older than X days in order …
0
Hello experts,

One of the application teams is using a java application to authenticate users and for SSO, the app authenticates the user and if his password is set to expire in 14 days, the app throws a message to the user that his password is expiring in 14 days, and the user clicks OK, and after that he is redirected to a server/app that uses SSO and the decryption of his password fails and he cannot login to the app (although the user is initially authenticated successfully). This only happens for users whose password is set to expire in 14 days. The java app is working fine for 99% of the users, except for those users whose password is set to expire in 14 days.

Any ideas as to how I could assist the application team, as to why this behavior, and what could be wrong.

Your assistance is much appreciated.
0
I am looking for a script (PowerShell or JS) that will create multiple Calendar overlays for a SharePoint online Calendar. I found some for SharePoint 2013, but it does not work for SharePoint online. When creating a SharePoint site template, Calendar Overlays are stripped. Unless anyone can think of another way of automatically creating them, Scripting seems the way to go.

Any help will be great. Thank you.
0
I want to write a script in Windows PowerShell ISE that will ask the user for their name and also ask a question to the user with three options. it need to run on of the options and display the output.
0
Hi All,

I have the below working script, though would like to pick some experts brains please.

A)Is there anything wrong, i.e, can I cause harm/damage if I am running the "Unlock-AD" if the actual account isn't even locked?

eg, should it include something like - If Username is locked, then Unlock?

B)Is the below formatting OK, or is there a better "Preferred/Recommended" way I should be using?

C)As I work in 1st/2nd Line Support I often get calls for AD unlocks, any other suggestions I should be running this script to make it more efficient

eg, does anyone use a script to search for surname and first name to pick up female name changes etc instead of by username or how else do others do their environment?

Thanks,

Import-Module ActiveDirectory

$Credentials = Get-Credential $UserName = Read-Host "Enter in the Username to check"

Get-ADUser $UserName -Properties Displayname, LockedOut, badPwdCount, AccountLockoutTime, PasswordExpired `
| Select-Object -Property Displayname, LockedOut, badPwdCount, AccountLockoutTime, PasswordExpired

Unlock-ADAccount $UserName -Credential $Credentials

Open in new window

0
cannot find SERVER Manager ( windows server 2012)cannot find SERVER Manager ( windows server 2012),i run a powershell script to enable multiple users and i restart rdp and now i cannot find servr manager how to enable it?
0
I am trying to create  a script that could help me create many folders. No problems with that, but I wanted to suppress the output of new-item . If I use  | out-null on a PS Prompt I see the Output remains suppressed, but when I use it in my script it does not suppress the output. Any idea?

-------------------------------------

Write-Host  "*** Welcome ***"
$path = get-location
$a = Read-Host "Enter the Number for Iteration 1"
$b = Read-Host "Enter the Number for Iteration 2"
for ($i=0;$i -lt $a ; $i++) { $i1 = $i+1 ; $pfname = "AAA$i1" ; Write-Host "Creating Parent Level Folder $pfname " ; New-Item -type Directory -path $path -name $pfname  | out-null ; for ($j=0 ; $j -lt $b ; $j++) { $childpath = "$path\$pfname"  ; $j1 = $j +1; $cfname = "BBB$j1" ; Write-Host "Creating Child Level Folder $cfname" ;  new-item -type Directory -path $childpath -name $cfname | out-null }}


--------------------------------------------------------------------------------
0
when i export Get-MailboxFolderStatistics username | Select Name, Identity,FolderandSubFolderSize,ItemsinFolderandSubfolders
there are items in  Top of Information Store, when I went to my outlook I do n ot see any items but when I uncheck "Show home page by default for this folder" I still see my mailbox have no items in Top of Information Store..

how is Get-MailboxFolderStatistics get these items and are there actually items in  Top of Information Store ?
0
Independent Software Vendors: We Want Your Opinion
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

i get the following error when i run the command

 .\Setup.exe /mode:Install /role:Mailbox /OrganizationName:"Eximghana" /IAcceptExchangeServerLicenseTerms

using powershell. kindly assist




Welcome to Microsoft Exchange Server 2016 Unattended Setup

Copying Files...
File copy complete.
Setup will now collect additional information needed for installation.


Performing Microsoft Exchange Server Prerequisite Check

    Prerequisite Analysis                                                                             100%

Setup will prepare the organization for Exchange Server 2016 by using 'Setup /PrepareAD'. No Exchange Server 2013 ro
have been detected in this topology. After this operation, you will not be able to install any Exchange Server 2013
roles.
For more information, visit: http://technet.microsoft.com/library(EXCHG.160)/ms.exch.setupreadiness.NoE15ServerWarni
spx

Setup will prepare the organization for Exchange Server 2016 by using 'Setup /PrepareAD'. No Exchange Server 2010 ro
have been detected in this topology. After this operation, you will not be able to install any Exchange Server 2010
roles.
For more information, visit: http://technet.microsoft.com/library(EXCHG.160)/ms.exch.setupreadiness.NoE14ServerWarni
spx


Configuring Microsoft Exchange Server

    Organization Preparation                                                                          100%
The following error was generated when "$error.Clear();
 …
0
Hello,

I have a CSV file which contains list of decommissioned computer names (CN).  

Is it possible to list if they still have an computer account in Active Directory?
0
Hi.

There must be a way to do this through powershell but I'm not sure. We've inherited a client that has their entire client list in separate folders and subfolders all in a shared mailbox.  It goes A - Z with about 50 GB of messages.

These are all old emails and I've finally convinced them to move all that data to a file server.

Outlook can only drag and drop emails not folders.

What's the best strategy here? To move these in bulk?
0
I am trying to create a script to search several computers and list what groups a specific user is a member of an export to a csv file.

Example:

ComputerA has a user called USERA that is a member of the local Administrators group and Remote Desktop Users group

ComputerB has a user called USERA that is a member of the local Administrators group and Backup Operators group

The cvs file would list the computer name, USERA, and groups that it is a member of

ComputerA,USERA,Administrators
ComputerA,USERA,Remote Desktop Users
ComputerB,USERA,Administrators
ComputerB,USERA,Backup Operators

Any help is greatly appreciated.
0
so i have 3 databases i am trying to reference to match cert ant criteria
databases as follows
historyMMYY (MM=current month as a 2 digit code & YY=current year as a 2 digit code) currently history1117
table "dbo.RecordHistory" has data laid out in the following relevant categories..
column1=RecordID, column2=CustomerID column5=Recorddate*(YYYY-MM-DD HH:MM:SS.000) GMT Times, column7=RecordZone, & column21=RawInfo
CUSTOMER
table "dbo.Customer Data" has data laid out in the following relevant categories..
column1=CustomerID, column2=CustomerCode, column3=CustomerNumber, & column6=name
table "dbo.Zone Data" has data laid out in the following relevant categories..
column1=CustomerID, column2=RecordZone, & column3=Discription
every minuet i would like to check for new lines on dbo.RecordHistory that corispond to "customerID" that have a "CustomerCode" of "XS" or "XSA".
i would like to format the data as filename="RecordID".txt
body=[CustomerCode]-[CustomerNumber] [name] (some other data from "dbo.RecordHistory") [RecordZone] [Discription] [RawInfo]
is this possible with a batch file, if not what about a Power shell script?
0
Hey

How do I sort version numbers: (in an array)

1.1.0.8400
1.10.0.14127
1.10.1.14414
1.11.0.14649
1.11.1.14865
1.12.0.15302
1.12.1.15602
1.12.1.15662
1.2.0.9064
1.4.0.10352
1.5.0.11365
1.5.0.11534
1.6.0.12058
1.7.0.12519
1.7.1.12780
1.8.0.13165
1.9.0.13640
1.9.1.13731
0
Hi,

I'm loading my globalvariables.ps1 in my $profile.
Now I'd like to have all my servers available with NETBIOS and FQDN, how can I achieve this?

To clarify, a piece of my globalvariables.ps1:

GENERAL ################################################################################################
$Global:DomainFQDN = $env:USERDNSDOMAIN

SERVERS ################################################################################################
$Global:SCCMSiteServer01 = 'SCCMSERVER'
$Global:ConnectionBroker01 = 'CONNECTIONBROKER'
#ADDING EXTRA SERVERS HERE

#FQDN
#FOR EACH SERVER, ADD A GLOBAL VARIABLE SERVER_FQDN, HOWTO DO THIS?
$Global:SCCMSiteServer01_FQDN =  ($SCCMSiteServer01 + '.' + $DomainFQDN))
$Global:ConnectionBroker01_FQDN = ($ConnectionBroker01 + '.' + $DomainFQDN)

Open in new window

0
Dear Wizards, we have a Shared File server 2012r2 (not in domain environment) in which has local users and shared folders with different permissions for its users. We are planning to rebuild the SharedFile server but at first we need to audit the users and their permissions on shared folders.

Therefore, how can we check it? (by cmd, powershell, or other tools) Does anyone have experience about it? Please help and many thanks as always!
0
We would like to restrict access to removable storage on our Windows 10 machines to one process (preferably via file hash).

Is that possible using something built into Windows - Group Policy, Powershell, etc?

Thanks,

David
0
What is SQL Server and how does it work?
LVL 1
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Hello everyone,
I just wanted to ask you if we are doing the most efficient way of resetting IIS and validating services on multiple computers.
 
Is this command could be simplified? We only have two servers where we are resetting IIS and 5 computers where we need to validate and set services.
 
Perhaps what we are doing here is NOT the most efficient process.
 
Let me know. Thank you so much!
 
1. At the elevated PowerShell prompt, run the commands below:
      a. Reset IIS
      $pors = (get-content "f:\software\servers.txt") | select-string "por0"
      Foreach ($por in $pors) {Invoke-command –ComputerName $por –ScriptBlock {iisreset}}

      b. Set all DEV services to Automatic - Running
      $servers = get-content -path "f:\software\servers.txt"
      Foreach ($server in $servers) {Invoke-command –ComputerName $server –ScriptBlock {get-service –displayname *DEV* | set-service –startuptype automatic –status running}}

      c. Validate all DEV services status
      $services = Foreach ($server in $servers) {Invoke-command –ComputerName $server –ScriptBlock {get-service –displayname *adms* | select pscomputername,displayname,status,starttype}}
      $services |format-table -autosize
 
0
While I have most of the ps written to change the registry value "config flag" on a system level I'm running into access issues. The model is HP EliteBook 810 G1 and the driver is Atmel Touch screen which needs to be disabled. Any assistance would be appreciated.
0
Hello there,
Would like to ask for some assistance. I have the following registry updates and would like to do an update to servers' registries in multiple forests. Can someone please shed some light?

invoke-command -Computer (Get-Content "C:\temp\listofservers.txt")
-ScriptBlock {
Set-ItemProperty HKLM:SYSTEM\CurrentControlSet\services\DNS\Parameters -Name EnableGlobalQueryBlockList-Value 0 -Propertytype DWORD -Force
Set-ItemProperty HKLM:SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters -Name SMB1 -Value 0 -PropertyType DWORD -Force
}

Thank you so much for your help!
0
why is it that everytime I open up exchange shell, I have to type the following command, or I get the error "the term "command" is not recognized as the name of a cmdlt....."

Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn;

Is there a way to have this stick, so I don't have to do this every time I open the exchange shell?
0
I need to update user parameter fields in AD like  Description , office , job tittle, Department, Conmpany and Manager.

I have a csv file from a payroll system that I need to use as master file ,

I would like a powershell script that can read the user file and update those fields in AD
0
Hi all,

We have a document library with various folders and files on SharePoint 2010.

We would like to make an automated job that copies the data from this library at the head office and paste it in a different environment at the Backup site.

Any suggestions what we can do? Example PowerShell script, SharePoint job etc…
0

Powershell

16K

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.